details:   https://code.openbravo.com/erp/devel/pi/rev/b23043be4cf6
changeset: 30494:b23043be4cf6
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Wed Sep 14 12:10:51 2016 +0200
summary:   Fixed Issue 33976: Implemented Pre Delete Client Side Event Handler

details:   https://code.openbravo.com/erp/devel/pi/rev/86421f907032
changeset: 30495:86421f907032
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Fri Sep 16 15:02:24 2016 +0200
summary:   Related ot issue 33976: Code review improvements


1) Take into account if the grid is in tree view or normal view.
2) Name selectedRecords as recordsToDelete.
3) Check if the callback function to be executed is a function. If not, don't 
execute the action.

details:   https://code.openbravo.com/erp/devel/pi/rev/a329a3cb0674
changeset: 30496:a329a3cb0674
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Fri Sep 16 15:49:50 2016 +0200
summary:   Related to issue 33976: Code review

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-event-handler-registry.js
 |   3 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
          |  28 +++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diffs (71 lines):

diff -r 6ae94a6a873d -r a329a3cb0674 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-event-handler-registry.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-event-handler-registry.js
        Tue Oct 18 11:45:46 2016 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-event-handler-registry.js
        Fri Sep 16 15:49:50 2016 +0200
@@ -27,8 +27,9 @@
 
   PRESAVE: 'PRESAVE',
   POSTSAVE: 'POSTSAVE',
+  PREDELETE: 'PREDELETE',
 
-  actionTypes: ['PRESAVE', 'POSTSAVE'],
+  actionTypes: ['PRESAVE', 'POSTSAVE', 'PREDELETE'],
 
   isValidElement: function (actionType) {
     var findType;
diff -r 6ae94a6a873d -r a329a3cb0674 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Tue Oct 18 11:45:46 2016 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Fri Sep 16 15:49:50 2016 +0200
@@ -2160,11 +2160,31 @@
     this.callSaveActions(OB.EventHandlerRegistry.PRESAVE, eventHandlerParams, 
saveRowCallback);
   },
 
+  executePreDeleteActions: function (deleteRowCallback) {
+    var eventHandlerParams = {},
+        currentGrid;
+
+    if (this.isShowingTree) {
+      currentGrid = this.treeGrid;
+    } else {
+      currentGrid = this.viewGrid;
+    }
+    eventHandlerParams.recordsToDelete = isc.clone(currentGrid.getSelection());
+    this.callClientEventHandlerActions(OB.EventHandlerRegistry.PREDELETE, 
eventHandlerParams, deleteRowCallback, true);
+  },
+
   existsAction: function (actionType) {
     return this.tabId && OB.EventHandlerRegistry.hasAction(this.tabId, 
actionType);
   },
 
   callSaveActions: function (actionType, extraParameters, callback) {
+    if (actionType !== OB.EventHandlerRegistry.PRESAVE && actionType !== 
OB.EventHandlerRegistry.POSTSAVE) {
+      return;
+    }
+    this.callClientEventHandlerActions(actionType, extraParameters, callback);
+  },
+
+  callClientEventHandlerActions: function (actionType, extraParameters, 
callback, executeCallback) {
     var params;
     if (this.existsAction(actionType)) {
       params = {
@@ -2177,6 +2197,8 @@
         callback: callback
       };
       OB.EventHandlerRegistry.call(params);
+    } else if (executeCallback && isc.A.Function(callback)) {
+      callback();
     }
   },
 
@@ -2337,8 +2359,10 @@
           }
         }
       };
-      isc.ask(msg, callback, {
-        title: dialogTitle
+      this.executePreDeleteActions(function () {
+        isc.ask(msg, callback, {
+          title: dialogTitle
+        });
       });
     }
   },

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to