[client-event-handlers] Implement post-save actions calling in standard forms
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 14 Jun 2016 19:47:01 +0200
changeset 29789 0b4f4281338d
parent 29788 f89fb4fc0f4f
child 29790 c918bb5c287b
[client-event-handlers] Implement post-save actions calling in standard forms
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Tue Jun 14 19:31:03 2016 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Tue Jun 14 19:47:01 2016 +0200
@@ -1614,7 +1614,7 @@
   saveRow: function (parameters) {
     var savingNewRecord = this.isNew,
         storedFocusItem, i, length, flds, form = this,
-        ficCallDone, record, recordIndex, callback, viewsNotToRefresh;
+        ficCallDone, record, recordIndex, callback, viewsNotToRefresh, autoSaveAction;
 
     if (this.getFocusItem()) {
       storedFocusItem = this.getFocusItem();
@@ -1648,10 +1648,15 @@
       this.view.messageBar.hide();
     }
 
+    if (this.view.standardWindow) {
+      autoSaveAction = this.view.standardWindow.autoSaveAction;
+    }
+
     callback = function (resp, data, req) {
       var index1, index2, view = form.view,
           localRecord, status = resp.status,
-          sessionProperties, keepSelection, gridRefreshCallback, theGrid, theId, id;
+          sessionProperties, keepSelection, gridRefreshCallback, theGrid, theId, id, eventHandlerParams = {},
+          eventHandlerCallback;
 
       if (this.hasOwnProperty('previousExplicitOffline')) {
         isc.Offline.explicitOffline = this.previousExplicitOffline;
@@ -1827,6 +1832,17 @@
         view.viewGrid.getSummaryRow();
       }
 
+      if (status === isc.RPCResponse.STATUS_SUCCESS && view.callSaveActions) {
+        eventHandlerParams.data = isc.clone(data);
+        eventHandlerParams.isNewRecord = savingNewRecord;
+        if (autoSaveAction) {
+          eventHandlerCallback = function () {
+            OB.Utilities.callAction(autoSaveAction);
+          };
+        }
+        view.callSaveActions('POSTSAVE', eventHandlerParams, eventHandlerCallback);
+      }
+
       return false;
     };