details:   https://code.openbravo.com/erp/devel/pi/rev/78e4e8656a9d
changeset: 17694:78e4e8656a9d
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu Aug 16 13:58:02 2012 +0200
summary:   Fixes issue 21361: Data can be saved in local server without 
internet access

Before this fix, it was not possible to save data without being connected, 
because of this code in the saveData function:

        if (isc.Offline && isc.Offline.isOffline() && 
!this.dataSource.clientOnly) {
            isc.warn(this.offlineSaveMessage);
            return;
        }

Offline.isOffline() is defined as follows:

    isOffline : function () {
        if (this.explicitOffline !== null) return this.explicitOffline;
        var offline = window.navigator.onLine ? false : true;
        return offline;
    }

So, by setting Offline.explicitOffline to false, it is possible to go on with 
the saving process even if the browser detects there is no internet 
connectivity.

This value is set just before the save, and restored to its original value 
right after the saving process is completed.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
 |  7 +++++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
 |  4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r 701b8b9f37de -r 78e4e8656a9d 
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
     Thu Aug 16 12:40:46 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Thu Aug 16 13:58:02 2012 +0200
@@ -1396,6 +1396,11 @@
           localRecord, status = resp.status,
           sessionProperties;
 
+      if (this.hasOwnProperty('previousExplicitOffline')) {
+        isc.Offline.explicitOffline = this.previousExplicitOffline;
+        delete this.previousExplicitOffline;
+      }
+
       // if no recordIndex then select explicitly
       if (recordIndex === -1) {
         var id = form.getValue('id');
@@ -1530,6 +1535,8 @@
       if (!form.validateForm()) {
         return;
       }
+      this.previousExplicitOffline = isc.Offline.explicitOffline;
+      isc.Offline.explicitOffline = false;
       // last parameter true prevents additional validation
       this.saveData(callback, {
         willHandleError: true,
diff -r 701b8b9f37de -r 78e4e8656a9d 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Thu Aug 16 12:40:46 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Thu Aug 16 13:58:02 2012 +0200
@@ -2240,6 +2240,7 @@
   // done, at that point first try to force a fic call (handleItemChange) and 
if that
   // indeed happens stop the saveEdit until the fic returns
   saveEditedValues: function (rowNum, colNum, newValues, oldValues, 
editValuesID, editCompletionEvent, saveCallback, ficCallDone) {
+    var previousExplicitOffline;
     if (!rowNum && rowNum !== 0) {
       rowNum = this.getEditRow();
     }
@@ -2274,7 +2275,10 @@
         }
       }
     }
+    previousExplicitOffline = isc.Offline.explicitOffline;
+    isc.Offline.explicitOffline = false;
     this.Super('saveEditedValues', [rowNum, colNum, newValues, oldValues, 
editValuesID, editCompletionEvent, saveCallback]);
+    isc.Offline.explicitOffline = previousExplicitOffline;
     // commented out as it removes an autosave action which is done in the 
edit complete method
     //    this.view.standardWindow.setDirtyEditForm(null);
   },

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to