issue #23956: delete line items remain
authorjulesstp <julianmcarlin@gmail.com>
Mon, 4 Aug 2014 22:05:51 +0000 (18:05 -0400)
committerjulesstp <julianmcarlin@gmail.com>
Mon, 4 Aug 2014 22:05:51 +0000 (18:05 -0400)
enyo-client/application/source/models/sales_order.js
lib/enyo-x/source/views/child_workspace.js
lib/enyo-x/source/views/grid_box.js

index b1d98ec..bff0375 100644 (file)
@@ -196,6 +196,10 @@ white:true*/
       return defaults;
     },
 
+    /* 
+      The whole purpose here was to throw the popup in the appropriate scenario.
+      Now that's happening in enyo - childWorkspace - deleteItem.
+
     destroy: function (options) {
       var status = this.getParent().get("status"),
         K = XM.SalesOrder,
@@ -220,7 +224,7 @@ white:true*/
       }
 
       this.notify(message, payload);
-    },
+    }, */
 
     isActive: function () {
       return this.get("status") === XM.SalesOrder.OPEN_STATUS;
index b0e57b9..c014f03 100644 (file)
@@ -155,39 +155,22 @@ trailing:true, white:true*/
       Delete the model of the selected item and remove it from the list
     */
     deleteItem: function () {
-      var that = this,
-        model = that.getCollection().at(this.getModelIndex()),
+      var model = this.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.
-            */
+          if (response.answer) {
             this.getActive().doPrevious();
-            model.destroy(destroyOptions);
+            model.on("statusChange", this.waterfall("onChildWorkspaceValueChange"));
+            model.destroy();
+            // Waterfall down event - handled by lineItem grid box's valueChange function which "refreshes" the list
+            //this.waterfall("onChildWorkspaceValueChange");
           }
         };
       this.doNotify({
         type: XM.Model.YES_NO_CANCEL,
         message: "_deleteLine?".loc(),
-        callback: callback,
-        success: callback
+        callback: callback
       });
-      //this.renderWorkspace();
     },
     /**
       Add a new model to the collection and bring up a blank editor to fill it in
index 17898fe..daedb9c 100644 (file)
@@ -246,7 +246,8 @@ trailing:true, white:true, strict: false*/
       ontap: "buttonTapped",
       onEnterOut: "enterOut",
       onMoveUp: "moveUp",
-      onMoveDown: "moveDown"
+      onMoveDown: "moveDown",
+      onChildWorkspaceValueChange: "valueChanged"
     },
     published: {
       attr: null,