details:   /erp/devel/pi/rev/2b1420ba8e0e
changeset: 10712:2b1420ba8e0e
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 16 18:03:14 2011 +0100
summary:   Solve issue that grid edit row uses values from previous row

details:   /erp/devel/pi/rev/5fe204bf4e5e
changeset: 10713:5fe204bf4e5e
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 16 18:03:55 2011 +0100
summary:   Solved focus in form when form gets opened

details:   /erp/devel/pi/rev/d13aa18ed16c
changeset: 10714:d13aa18ed16c
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 16 18:04:25 2011 +0100
summary:   Override different method (saveEditValues) for calling fic at save

details:   /erp/devel/pi/rev/72ba6238f364
changeset: 10715:72ba6238f364
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 16 18:05:04 2011 +0100
summary:   Change way canFilter is set to prevent jslint error

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
         |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
             |  29 +++++----
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
             |  18 +++--
 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java
 |   3 +-
 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
 |   6 ++
 5 files changed, 37 insertions(+), 21 deletions(-)

diffs (170 lines):

diff -r 6ec51560e44c -r 72ba6238f364 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 16 17:07:02 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 16 18:05:04 2011 +0100
@@ -1458,7 +1458,7 @@
     if (this.isEditingGrid) {
       rowNum = this.viewGrid.getEditRow();
       if (rowNum || rowNum === 0) {
-        record = isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewGrid.getEditValues(rowNum));
+        record = isc.addProperties({}, this.viewGrid.getRecord(rowNum), 
this.viewGrid.getEditValues(rowNum));
       } else {
         record = isc.addProperties({}, this.viewGrid.getSelectedRecord());
       }
diff -r 6ec51560e44c -r 72ba6238f364 
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 Feb 16 17:07:02 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Wed Feb 16 18:05:04 2011 +0100
@@ -44,6 +44,8 @@
   autoComplete: true,
   redrawOnDisable: true,
   
+  autoFocus: true,
+  
   // ** {{ Layout Settings }} **
   numCols: 4,
   colWidths: ['24%', '24%', '24%', '24%'],
@@ -109,7 +111,7 @@
   
   editRecord: function(record, preventFocus){
     var ret = this.Super('editRecord', arguments);
-    this.doEditRecordActions(preventFocus, false);    
+    this.doEditRecordActions(preventFocus, false);
     return ret;
   },
   
@@ -142,7 +144,9 @@
     } else {
       this.view.statusBar.setStateLabel();
     }
-    
+    if (!preventFocus) {
+      this.resetFocusItem();
+    }
   },
   
   editNewRecord: function(preventFocus){
@@ -191,11 +195,13 @@
   resetFocusItem: function() {
     var items = this.getItems(), length = items.length, item;
 
-    if(!this.isDrawn()) {
-      isc.Page.setEvent(isc.EH.IDLE, this, isc.Page.FIRE_ONCE, 
'resetFocusItem');
+    // is set for inline grid editing for example
+    if (this.getFocusItem() && this.getFocusItem().getCanFocus()) {
+      this.getFocusItem().focusInItem();
+      this.view.lastFocusedField = this.getFocusItem();
       return;
     }
-
+    
     if(this.firstFocusedField) {
       item = this.getItem(this.firstFocusedField);
       if(item && item.getCanFocus()) {
@@ -221,11 +227,6 @@
     var focusItem = this.getFocusItem(), item, items = this.getItems(),
         length = items.length;
 
-    if(!this.isDrawn()) {
-      isc.Page.setEvent(isc.EH.IDLE, this, isc.Page.FIRE_ONCE, 
'resetFocusItem');
-      return;
-    }
-
     if(this.firstFocusedField) {
       item = this.getItem(this.firstFocusedField);
       if(item && item.getCanFocus()) {
@@ -319,8 +320,10 @@
         editValues = me.view.viewGrid.getEditValues(editRow);
       }
       me.processFICReturn(response, data, request, editValues, editRow);
-      // remember the initial values 
-      me.rememberValues();
+      if (!this.grid || this.grid.getEditRow() !== editRow) {
+        // remember the initial values, if we are still editing the same row
+        me.rememberValues();
+      }
     });
   },
   
@@ -412,6 +415,8 @@
     this.markForRedraw();
     if (this.showFormOnFICReturn) {
       if (!this.isVisible()) {
+        this.setFocusItem(null);
+        this.resetFocusItem();
         this.view.switchFormGridVisibility();
       }
       delete this.showFormOnFICReturn;
diff -r 6ec51560e44c -r 72ba6238f364 
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 Feb 16 17:07:02 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Wed Feb 16 18:05:04 2011 +0100
@@ -1223,31 +1223,35 @@
   // latest values. This can happen when the focus is in a field and the save 
action is
   // done, at that point first try to force a fic call (handleItemChange) and 
if that
   // indeed happens stop the saveEdit until the fic returns
-  saveEdits: function(editCompletionEvent, callback, rowNum, colNum, 
validateOnly, ficCallDone){
+  saveEditedValues: function (rowNum, colNum, newValues, oldValues, 
+                             editValuesID, editCompletionEvent, saveCallback, 
ficCallDone) {
     if (!rowNum && rowNum !== 0) {
       rowNum = this.getEditRow();
     }
     if (!colNum && colNum !== 0) {
       colNum = this.getEditCol();
     }
-    if (!validateOnly && !ficCallDone) {
+    if (ficCallDone) {
+      // reset the new values as this can have changed because of a fic call
+      newValues = this.getEditValues(editValuesID);
+    } else {
       var editForm = this.getEditForm(), focusItem = editForm.getFocusItem();
       if (focusItem) {
         focusItem.updateValue();
-        editForm.handleItemChange(focusItem);        
+        editForm.handleItemChange(focusItem);
         if (editForm.inFicCall) {
           // use editValues object as the edit form will be re-used for a next 
row
-          var editValues = this.getEditValues(rowNum);
+          var editValues = this.getEditValues(editValuesID);
           editValues.actionAfterFicReturn = {
             target: this,
-            method: this.saveEdits,
-            parameters: [editCompletionEvent, callback, rowNum, colNum, 
validateOnly, true]
+            method: this.saveEditedValues,
+            parameters: [rowNum, colNum, newValues, oldValues, editValuesID, 
editCompletionEvent, saveCallback, true]
           };
           return;
         }
       }
     }
-    this.Super('saveEdits', arguments);
+    this.Super('saveEditedValues', [rowNum, colNum, newValues, oldValues, 
editValuesID, editCompletionEvent, saveCallback]);
   },
 
   autoSave: function(){
diff -r 6ec51560e44c -r 72ba6238f364 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java
--- 
a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java
      Wed Feb 16 17:07:02 2011 +0100
+++ 
b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java
      Wed Feb 16 18:05:04 2011 +0100
@@ -689,7 +689,8 @@
       final List<LocalSelectorFieldProperty> result = new 
ArrayList<LocalSelectorFieldProperty>();
       result.add(createLocalSelectorFieldProperty("title", title));
       result.add(createLocalSelectorFieldProperty("name", name));
-      result.add(createLocalSelectorFieldProperty("canFilter", filter));
+      // is used at runtime to set canFilter on false for a field
+      result.add(createLocalSelectorFieldProperty("disableFilter", filter));
       result.add(createLocalSelectorFieldProperty("canSort", sort));
       result.add(createLocalSelectorFieldProperty("type", getType()));
       if ((domainType instanceof PrimitiveDomainType)) {
diff -r 6ec51560e44c -r 72ba6238f364 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
--- 
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Wed Feb 16 17:07:02 2011 +0100
+++ 
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Wed Feb 16 18:05:04 2011 +0100
@@ -52,6 +52,12 @@
     
     OB.Utilities.applyDefaultValues(this.selectorGridFields, 
this.defaultSelectorGridField);
     
+    for (var i = 0; i < this.selectorGridFields.length; i++) {
+      if (this.selectorGridFields[i].disableFilter) {
+        this.selectorGridFields[i].canFilter = false;
+      }
+    }
+    
     this.selectorGrid = isc.OBGrid.create({
     
       selector: this.selector,

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to