details:   https://code.openbravo.com/erp/devel/pi/rev/155025bf029e
changeset: 17790:155025bf029e
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Tue Aug 28 18:40:44 2012 +0200
summary:   Fixed issue 21382: [KS] 'ESC' key now works ok in grid view
(it cancels the row edit)

diffstat:

 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
                 |   1 -
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
 |   4 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
      |  15 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
 |  45 +++++----
 4 files changed, 41 insertions(+), 24 deletions(-)

diffs (167 lines):

diff -r 2fa2537a618f -r 155025bf029e 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
     Thu Aug 23 15:11:53 2012 +0200
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
     Tue Aug 28 18:40:44 2012 +0200
@@ -50,7 +50,6 @@
   {"id": "ViewGrid_EditInGrid", "keyComb": {"key": "f2"}},
   {"id": "ViewGrid_CancelEditing", "keyComb": {"key": "Escape"}},
   {"id": "ViewGrid_DeleteSelectedRecords", "keyComb": {"key": "Delete"}},
-  {"id": "ViewGrid_CancelChanges", "keyComb": {"key": "Escape"}},
   {"id": "ViewForm_OpenLinkOut", "keyComb": {"ctrl": true, "alt": true, "key": 
"Enter"}},
   {"id": "Selector_ShowPopup", "keyComb": {"ctrl": true, "key": "Enter"}},
   {"id": "SelectorLink_ShowPopup", "keyComb": {"ctrl": true, "key": "Enter"}}
diff -r 2fa2537a618f -r 155025bf029e 
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 23 15:11:53 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Tue Aug 28 18:40:44 2012 +0200
@@ -1807,6 +1807,10 @@
   },
 
   keyDown: function () {
+    if (this.grid && this.grid.editFormKeyDown) {
+      // To fix issue https://issues.openbravo.com/view.php?id=21382
+      this.grid.editFormKeyDown(arguments);
+    }
     var response = OB.KeyboardManager.Shortcuts.monitor('OBViewForm');
     if (response !== false) {
       response = this.Super('keyDown', arguments);
diff -r 2fa2537a618f -r 155025bf029e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
  Thu Aug 23 15:11:53 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
  Tue Aug 28 18:40:44 2012 +0200
@@ -68,7 +68,7 @@
       me.focusInFirstFilterEditor();
       return false; //To avoid keyboard shortcut propagation
     };
-    OB.KeyboardManager.Shortcuts.set('Grid_FocusFilter', 'OBGrid.body', 
ksAction_FocusFilter);
+    OB.KeyboardManager.Shortcuts.set('Grid_FocusFilter', ['OBGrid.body', 
'OBGrid.editForm'], ksAction_FocusFilter);
 
     ksAction_FocusGrid = function () {
       me.focus();
@@ -80,7 +80,7 @@
       me.clearFilter(true);
       return false; //To avoid keyboard shortcut propagation
     };
-    OB.KeyboardManager.Shortcuts.set('Grid_ClearFilter', ['OBGrid.body', 
'OBGrid.filter'], ksAction_ClearFilter);
+    OB.KeyboardManager.Shortcuts.set('Grid_ClearFilter', ['OBGrid.body', 
'OBGrid.filter', 'OBGrid.editForm'], ksAction_ClearFilter);
 
     ksAction_SelectAll = function () {
       me.selectAllRecords();
@@ -103,7 +103,7 @@
   },
 
   bodyKeyPress: function (event, eventInfo) {
-    if ((eventInfo.keyName === isc.OBViewGrid.ARROW_UP_KEY_NAME && 
this.data.localData[0].id === this.lastSelectedRecord.id) || (eventInfo.keyName 
=== isc.OBViewGrid.ARROW_DOWN_KEY_NAME && 
this.data.localData[this.data.localData.length - 1] && 
this.data.localData[this.data.localData.length - 1].id === 
this.lastSelectedRecord.id)) {
+    if (eventInfo && this.lastSelectedRecord && ((eventInfo.keyName === 
isc.OBViewGrid.ARROW_UP_KEY_NAME && this.data.localData[0].id === 
this.lastSelectedRecord.id) || (eventInfo.keyName === 
isc.OBViewGrid.ARROW_DOWN_KEY_NAME && 
this.data.localData[this.data.localData.length - 1] && 
this.data.localData[this.data.localData.length - 1].id === 
this.lastSelectedRecord.id))) {
       return true;
     }
     var response = OB.KeyboardManager.Shortcuts.monitor('OBGrid.body');
@@ -113,6 +113,15 @@
     return response;
   },
 
+  editFormKeyDown: function () {
+    // Custom method. Only works if the form is an OBViewForm
+    var response = OB.KeyboardManager.Shortcuts.monitor('OBGrid.editForm');
+    if (response !== false) {
+      response = this.Super('editFormKeyDown', arguments);
+    }
+    return response;
+  },
+
   filterFieldsKeyDown: function (item, form, keyName) {
     var response = OB.KeyboardManager.Shortcuts.monitor('OBGrid.filter');
     if (response !== false) {
diff -r 2fa2537a618f -r 155025bf029e 
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 23 15:11:53 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Tue Aug 28 18:40:44 2012 +0200
@@ -693,7 +693,7 @@
   bodyKeyPress: function (event, eventInfo) {
     var response = OB.KeyboardManager.Shortcuts.monitor('OBViewGrid.body');
     if (response !== false) {
-      if (event.keyName === 'Space' && (isc.EventHandler.ctrlKeyDown() || 
isc.EventHandler.altKeyDown() || isc.EventHandler.shiftKeyDown())) {
+      if (event && event.keyName === 'Space' && 
(isc.EventHandler.ctrlKeyDown() || isc.EventHandler.altKeyDown() || 
isc.EventHandler.shiftKeyDown())) {
         return true;
       }
       response = this.Super('bodyKeyPress', arguments);
@@ -701,6 +701,15 @@
     return response;
   },
 
+  editFormKeyDown: function () {
+    // Custom method. Only works if the form is an OBViewForm
+    var response = OB.KeyboardManager.Shortcuts.monitor('OBViewGrid.editForm');
+    if (response !== false) {
+      response = this.Super('editFormKeyDown', arguments);
+    }
+    return response;
+  },
+
   // called when the view gets activated
   setActive: function (active) {
     if (active) {
@@ -723,16 +732,7 @@
     var me = this,
         ksAction_CancelEditing, ksAction_MoveUpWhileEditing, 
ksAction_MoveDownWhileEditing, ksAction_DeleteSelectedRecords, 
ksAction_EditInGrid, ksAction_EditInForm, ksAction_CancelChanges;
 
-    ksAction_CancelEditing = function () {
-      if (me.getEditForm()) {
-        me.cancelEditing();
-        return false; //To avoid keyboard shortcut propagation
-      } else {
-        return true;
-      }
-    };
-    OB.KeyboardManager.Shortcuts.set('ViewGrid_CancelEditing', ['OBViewGrid', 
'OBViewGrid.body'], ksAction_CancelEditing);
-
+    // This is JUST for the case of an editing row with the whole row in "read 
only mode"
     ksAction_MoveUpWhileEditing = function () {
       if (me.getEditForm()) {
         var editRow = me.getEditRow();
@@ -745,10 +745,11 @@
         return true;
       }
     };
-    OB.KeyboardManager.Shortcuts.set('ViewGrid_MoveUpWhileEditing', 
['OBViewGrid', 'OBViewGrid.body'], ksAction_MoveUpWhileEditing, null, {
+    OB.KeyboardManager.Shortcuts.set('ViewGrid_MoveUpWhileEditing', 
'OBViewGrid.body', ksAction_MoveUpWhileEditing, null, {
       "key": "Arrow_Up"
     });
 
+    // This is JUST for the case of an editing row with the whole row in "read 
only mode"
     ksAction_MoveDownWhileEditing = function () {
       if (me.getEditForm()) {
         var editRow = me.getEditRow();
@@ -761,10 +762,20 @@
         return true;
       }
     };
-    OB.KeyboardManager.Shortcuts.set('ViewGrid_MoveDownWhileEditing', 
['OBViewGrid', 'OBViewGrid.body'], ksAction_MoveDownWhileEditing, null, {
+    OB.KeyboardManager.Shortcuts.set('ViewGrid_MoveDownWhileEditing', 
'OBViewGrid.body', ksAction_MoveDownWhileEditing, null, {
       "key": "Arrow_Down"
     });
 
+    ksAction_CancelEditing = function () {
+      if (me.getEditForm()) {
+        me.cancelEditing();
+        return false; //To avoid keyboard shortcut propagation
+      } else {
+        return true;
+      }
+    };
+    OB.KeyboardManager.Shortcuts.set('ViewGrid_CancelEditing', 
['OBViewGrid.body', 'OBViewGrid.editForm'], ksAction_CancelEditing);
+
     ksAction_DeleteSelectedRecords = function () {
       var isDeletingEnabled = 
!me.view.toolBar.getLeftMember(isc.OBToolbar.TYPE_DELETE).disabled;
       if (me.getSelectedRecords().length > 0 && isDeletingEnabled) {
@@ -796,13 +807,7 @@
         return true;
       }
     };
-    OB.KeyboardManager.Shortcuts.set('ViewGrid_EditInForm', 'OBViewGrid.body', 
ksAction_EditInForm);
-
-    ksAction_CancelChanges = function () {
-      me.view.undo();
-      return false;
-    };
-    OB.KeyboardManager.Shortcuts.set('ViewGrid_CancelChanges', 
'OBViewGrid.body', ksAction_CancelChanges);
+    OB.KeyboardManager.Shortcuts.set('ViewGrid_EditInForm', 
['OBViewGrid.body', 'OBViewGrid.editForm'], ksAction_EditInForm);
 
     this.Super('enableShortcuts', arguments);
   },

------------------------------------------------------------------------------
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