details:   https://code.openbravo.com/erp/devel/pi/rev/7d7b36e1e61e
changeset: 24989:7d7b36e1e61e
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Oct 03 13:12:58 2014 +0200
summary:   Related with issue 27730: Adds missing js formatting

details:   https://code.openbravo.com/erp/devel/pi/rev/ff95c8c768e7
changeset: 24990:ff95c8c768e7
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Oct 03 13:46:05 2014 +0200
summary:   Fixes issue 27730: Pressing enter in the last editable grid line 
creates record

The fix [1] of this issue [2] added a check to prevent creating a new line 
when, in an editable grid, a value was selected from a picklist by pressing the 
Enter key. The fix consisted in overwriting the ha
ndleKeyPress function of TextItem. The problem was that because of the way the 
fix was implemented, the new function was invoked but the original 
implementation of TextItem.handleKeyPress was never execute
d. This missing code was causing a strange behaviour in how the EventHandler 
set the items that are object of the events, and as a result of this the 
current issue was being reproducible.

To fix this, the issue [2] has been implemented differently. The root cause of 
that issue is that the keyDown event was done in a formitem (the selector) and 
the keyPress on another item (in this case the
description column). When this was detected, the call the handleKeyPress was 
intercepted to prevent adding a new line. Now, the interception is done in the 
cellEditEnd. This has two benefits:
- handleKeyPress is not overwritten, so the problems caused by the missing 
TextItem.handleKeyPress invocation disappear
- the interception is done in a more specific point. handleKeyPress is called 
constantly, but the cellEditEnd is only called when the focus leaves a grid 
cell.

[1] 
https://code.openbravo.com/erp/devel/pi/rev/b4ba48792e4850c804c42001d8f818f1e0575f81
[2] https://issues.openbravo.com/view.php?id=26817

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
            |   7 ++++
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
 |  17 ++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

diffs (51 lines):

diff -r 3ef590495e30 -r ff95c8c768e7 
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 Oct 02 11:55:57 2014 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Fri Oct 03 13:46:05 2014 +0200
@@ -3164,6 +3164,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
diff -r 3ef590495e30 -r ff95c8c768e7 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- 
a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Thu Oct 02 11:55:57 2014 +0000
+++ 
b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Fri Oct 03 13:46:05 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);
   }
 });
 
@@ -774,7 +771,7 @@
   },
   _originalEvalResult: isc.RPCManager.evalResult,
   evalResult: function (request, response, results) {
-       // if the response contains an error status, call the errorCallback
+    // if the response contains an error status, call the errorCallback
     if (response.status !== isc.RPCResponse.STATUS_SUCCESS && 
isc.isA.Function(request.errorCallback)) {
       request.errorCallback(request, response);
     }

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to