delete line item popup to come from enyo, not backbone so that we can handle enyo...
authorjulesstp <julianmcarlin@gmail.com>
Fri, 1 Aug 2014 20:16:59 +0000 (16:16 -0400)
committerjulesstp <julianmcarlin@gmail.com>
Fri, 1 Aug 2014 20:16:59 +0000 (16:16 -0400)
lib/enyo-x/source/views/child_workspace.js

index a09a2a1..b0e57b9 100644 (file)
@@ -155,8 +155,39 @@ trailing:true, white:true*/
       Delete the model of the selected item and remove it from the list
     */
     deleteItem: function () {
-      this.getCollection().at(this.getModelIndex()).destroy();
-      this.renderWorkspace();
+      var that = this,
+        model = that.getCollection().at(this.getModelIndex()),
+        message = "_unsavedChanges".loc() + " " + "_saveYourWork?".loc(),
+        callback = function (response) {
+          var answer = response.answer,
+            destroyOptions = {};
+          destroyOptions.success = function () {
+            console.log("in deleteItem's destroy success");
+            //ws.$.salesOrderLineItemBox.valueChanged()
+            //this.doPrevious();
+            /*
+            this.getCollection().at(this.getModelIndex()).destroy();
+            this.renderWorkspace();
+            */
+            
+          };
+
+          if (answer) {
+            /** Seems to be, after the destroy, what would normally be handled inside the grid box
+                to refresh and remove the model from the collection is not happening because we're
+                still in the workspce. Try doPrevious() first.
+            */
+            this.getActive().doPrevious();
+            model.destroy(destroyOptions);
+          }
+        };
+      this.doNotify({
+        type: XM.Model.YES_NO_CANCEL,
+        message: "_deleteLine?".loc(),
+        callback: callback,
+        success: callback
+      });
+      //this.renderWorkspace();
     },
     /**
       Add a new model to the collection and bring up a blank editor to fill it in