[client-event-handlers] Execute pre-save actions after auto-save confirmation
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 16 Jun 2016 09:59:01 +0200
changeset 29794 93a252909ec5
parent 29793 1ae3e064a1b5
child 29795 d7b00f5a135c
[client-event-handlers] Execute pre-save actions after auto-save confirmation
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Thu Jun 16 09:20:49 2016 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Thu Jun 16 09:59:01 2016 +0200
@@ -776,7 +776,13 @@
 
   doActionAfterAutoSave: function (action, forceDialogOnFailure, ignoreAutoSaveEnabled) {
     var me = this,
-        saveCallback;
+        preSaveCallback, saveCallback;
+
+    preSaveCallback = function (ok) {
+      me.activeView.executePreSaveActions(function () {
+        saveCallback(ok);
+      });
+    };
 
     saveCallback = function (ok) {
       var dirtyEditForm = me.getDirtyEditForm();
@@ -845,13 +851,15 @@
         OB.Utilities.callAction(action);
         return;
       }
+      if (this.getDirtyEditForm() && this.activeView.existsAction && this.activeView.existsAction('PRESAVE')) {
+        isc.ask(OB.I18N.getLabel('OBUIAPP_AutosaveConfirm'), preSaveCallback);
+        return;
+      }
       isc.ask(OB.I18N.getLabel('OBUIAPP_AutosaveConfirm'), saveCallback);
     } else {
       // Auto save confirmation not required: continue as confirmation was accepted
       if (this.getDirtyEditForm() && this.activeView.existsAction && this.activeView.existsAction('PRESAVE')) {
-        this.activeView.executePreSaveActions(function () {
-          saveCallback(true);
-        });
+        preSaveCallback(true);
         return;
       }
       saveCallback(true);