Related with issue 27730: Adds missing js formatting
authorAugusto Mauch <augusto.mauch@openbravo.com>
Fri, 03 Oct 2014 13:12:58 +0200
changeset 24076 541489ec5169
parent 24075 e33eb7ed352a
child 24077 ba2eb656f29e
Related with issue 27730: Adds missing js formatting
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Oct 03 16:26:24 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Oct 03 13:12:58 2014 +0200
@@ -3066,6 +3066,13 @@
     var newRow = nextEditCell && nextEditCell[0] !== rowNum;
     var enterKey = editCompletionEvent === 'enter';
 
+    // if event was triggered by pressing the enter key, do not continue if the current edit field is not the one focused when the enter key was pressed
+    // this happens for instance when a value is selected from a pick list by pressing enter. if that happens the value is selected, the focus is moved to the 
+    // next form item and the cellEditEnd function can be invoked for the form item that just got the focus
+    if (enterKey && editField.name !== this.getEditForm().lastKeyDownItem.name) {
+      return;
+    }
+
     // no newValue, compute it, this because in the super method there is a check
     // how many arguments are passed on, sometimes the newValue is not passed in
     // and then it must be recomputed, so if we then use the undefined newValue
@@ -3975,4 +3982,4 @@
     this.Super('showMember', arguments);
   }
 
-});
\ No newline at end of file
+});
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Oct 03 16:26:24 2014 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Oct 03 13:12:58 2014 +0200
@@ -520,15 +520,12 @@
     return this.Super('useDisabledEventMask', arguments);
   },
 
-  // handles a corner case where the event of the previous field is called for the current field,
-  // refer issue https://issues.openbravo.com/view.php?id=26817. In this case, the event is not triggered.
-  handleKeyPress: function (event, eventInfo) {
-    var key = isc.EH.lastEvent.keyName;
-    if (key === 'Enter' && event.itemInfo && event.itemInfo.item && event.itemInfo.item.name && event.itemInfo.item.name !== this.name) {
-      return true;
-    } else {
-      return this.Super('handleKeyPress', arguments);
-    }
+  // store the item that was focused when the key is pressed
+  // this information is then used in the OBViewGrid.cellEditEnd function. See issue https://issues.openbravo.com/view.php?id=27730
+  _original_handleKeyDown: isc.TextItem.getPrototype().handleKeyDown,
+  handleKeyDown: function (event, eventInfo) {
+    this.form.lastKeyDownItem = this;
+    return this._original_handleKeyDown(event, eventInfo);
   }
 });
 
@@ -891,4 +888,4 @@
 delete isc.DataSource.getSearchOperators().equals.wildCard;
 delete isc.DataSource.getSearchOperators().iEquals.wildCard;
 delete isc.DataSource.getSearchOperators().notEqual.wildCard;
-delete isc.DataSource.getSearchOperators().iNotEqual.wildCard;
\ No newline at end of file
+delete isc.DataSource.getSearchOperators().iNotEqual.wildCard;