details:   /erp/devel/pi/rev/e056ce5721bb
changeset: 11524:e056ce5721bb
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Apr 07 09:37:25 2011 +0200
summary:   Fixes issue 16603: Autosave disabled doesn't work on grid

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
 |   9 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
  |   2 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
        |   6 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
        |  35 ++++++++-
 4 files changed, 43 insertions(+), 9 deletions(-)

diffs (143 lines):

diff -r 8e3d08f05c01 -r e056ce5721bb 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Wed Apr 06 19:59:01 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Thu Apr 07 09:37:25 2011 +0200
@@ -511,7 +511,7 @@
   moveFocusOnPickValue: true,
   
   // is overridden to keep track that a value has been explicitly picked
-  pickValue : function (value) {
+  pickValue: function (value) {
     this._pickedValue = true;
     this.Super('pickValue', arguments);
     delete this._pickedValue;
@@ -898,6 +898,13 @@
   change: function(form, item, value, oldValue){ /* transformInput */
     var isADate = value !== null &&
               Object.prototype.toString.call(value) === '[object Date]';
+    // prevent a change if nothing changed
+    if (value === oldValue) {
+      return false;
+    }
+    if (isADate && value && oldValue && oldValue.getTime && value.getTime() 
=== oldValue.getTime()) {
+      return false;
+    }
     if (isADate) {
       return;
     }
diff -r 8e3d08f05c01 -r e056ce5721bb 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Wed Apr 06 19:59:01 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Thu Apr 07 09:37:25 2011 +0200
@@ -225,6 +225,7 @@
     }
 
     var callback = function(ok){
+      delete me.inAutoSaveConfirmation;
       if (ok) {
         if (me.getDirtyEditForm()) {
           me.getDirtyEditForm().resetForm();
@@ -242,6 +243,7 @@
         }
       }
     };
+    this.inAutoSaveConfirmation = true;
     isc.ask(OB.I18N.getLabel('OBUIAPP_AutoSaveNotPossibleExecuteAction'), 
callback);
   },
   
diff -r 8e3d08f05c01 -r e056ce5721bb 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Wed Apr 06 19:59:01 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Thu Apr 07 09:37:25 2011 +0200
@@ -771,7 +771,10 @@
 
     // disable with a delay to allow the focus to be moved to a new field
     // before disabling
-    this.delayCall('setDisabled', [true], 10);
+    // only do this if there is no popup currently
+    if (!this.view.standardWindow.inAutoSaveConfirmation) {
+      this.delayCall('setDisabled', [true], 10);
+    }
 
     var editRow = this.view.viewGrid.getEditRow();
     
@@ -1025,7 +1028,6 @@
       }
       return;
     }
-    this.resetFocusItem();
   },
   
   getFirstErrorItem: function() {
diff -r 8e3d08f05c01 -r e056ce5721bb 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Wed Apr 06 19:59:01 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Apr 07 09:37:25 2011 +0200
@@ -1268,6 +1268,10 @@
         }        
       }
     }
+    if (colNum || colNum === 0) {
+      this.forceFocusColumn = this.getField(colNum).name;
+    }
+    
     return this.Super('startEditing', [rowNum, colNum, suppressFocus, eCe, 
suppressWarning]);
   },
 
@@ -1468,14 +1472,25 @@
   // check if a fic call needs to be done when leaving a cell and moving to 
the next
   // row
   // see description in saveEditvalues
-  cellEditEnd : function (editCompletionEvent, newValue, ficCallDone) {
+  cellEditEnd: function (editCompletionEvent, newValue, ficCallDone, 
autoSaveDone) {
     var rowNum = this.getEditRow(), colNum = this.getEditCol();
+    var editForm = this.getEditForm(), focusItem = editForm.getFocusItem();
+    var nextEditCell = this.getNextEditCell(rowNum, colNum, 
editCompletionEvent);
+    var newRow = nextEditCell && nextEditCell[0] !== rowNum;
+    if (!autoSaveDone && newRow && (this.getEditForm().hasChanged || 
this.getEditForm().isNew)) {
+      var actionObject = {
+          target: this,
+          method: this.cellEditEnd,
+          parameters: [editCompletionEvent, newValue, ficCallDone, true]
+        };
+      this.view.standardWindow.doActionAfterAutoSave(actionObject, true);
+      return;
+    }
     if (ficCallDone) {
       // get new value as the row can have changed
-      this.Super('cellEditEnd', [editCompletionEvent, 
this.getEditValue(rowNum, colNum), ficCallDone]);
+      this.Super('cellEditEnd', [editCompletionEvent, 
this.getEditValue(rowNum, colNum)]);
       return;
     } else {
-      var editForm = this.getEditForm(), focusItem = editForm.getFocusItem();
       if (focusItem) {
         focusItem.updateValue();
         editForm.handleItemChange(focusItem);
@@ -1485,13 +1500,17 @@
           editValues.actionAfterFicReturn = {
             target: this,
             method: this.cellEditEnd,
-            parameters: [editCompletionEvent, newValue, true]
+            parameters: [editCompletionEvent, newValue, true, autoSaveDone]
           };
           return;
         }
       }      
-    }    
-    this.Super('cellEditEnd', arguments);
+    }
+    if (newValue) {
+      this.Super('cellEditEnd', [editCompletionEvent, newValue]);
+    } else {
+      this.Super('cellEditEnd', [editCompletionEvent]);
+    }
   },
   
   // overridden to set the enterkeyaction to nextrowstart in cases the current 
row
@@ -1614,6 +1633,10 @@
       // if the focus does not get suppressed then the clicked field will 
receive focus
       // and won't be disabled so the user can already start typing      
       suppressFocus = true;
+
+      if (!this.forceFocusColumn && (colNum || colNum === 0)) {
+        this.forceFocusColumn = this.getField(colNum).name;
+      }
     }
     
     var ret = this.Super('showInlineEditor', [rowNum, colNum, newCell, newRow, 
suppressFocus]);

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to