details:   https://code.openbravo.com/erp/devel/pi/rev/fe9b93ae554e
changeset: 20225:fe9b93ae554e
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Mon Apr 29 12:02:57 2013 +0200
summary:   Fixed issue 23602: Now 'Del' key in grid performs
the same action than Toolbat 'Eliminate' button (if exists)

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
 |  53 ++++++---
 1 files changed, 33 insertions(+), 20 deletions(-)

diffs (76 lines):

diff -r 5e5dd4a8b5c0 -r fe9b93ae554e 
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
     Sun Apr 28 12:45:45 2013 +0530
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Mon Apr 29 12:02:57 2013 +0200
@@ -1348,9 +1348,8 @@
     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) {
-        me.view.deleteSelectedRows();
+      var isRecordDeleted = me.deleteSelectedRowsByToolbarIcon();
+      if (isRecordDeleted) {
         return false; // To avoid keyboard shortcut propagation
       } else {
         return true;
@@ -2178,29 +2177,43 @@
         title: OB.I18N.getLabel('OBUIAPP_Delete'),
         keyTitle: OB.KeyboardManager.Shortcuts.getProperty('keyComb.text', 
'ToolBar_Eliminate', 'id'),
         click: function () {
-          // The click action should be the same than the toolbar button, so 
if this last one is overwritten, this click should perform the same action.
-          var isToolbarButtonFound = false,
-              i;
-          if (grid.view.toolBar && grid.view.toolBar.leftMembers && 
isc.OBToolbar.TYPE_DELETE) {
-            for (i = 0; i < grid.view.toolBar.leftMembers.length; i++) {
-              if (grid.view.toolBar.leftMembers[i].buttonType === 
isc.OBToolbar.TYPE_DELETE) {
-                isToolbarButtonFound = true;
-                grid.view.toolBar.leftMembers[i].action();
-                break;
-              }
-            }
-          }
-          // But if the toolbar button is not found, do the default action
-          if (!isToolbarButtonFound) {
-            grid.view.deleteSelectedRows();
-          }
+          grid.deleteSelectedRowsByToolbarIcon();
         }
       });
     }
-
     return menuItems;
   },
 
+  deleteSelectedRowsByToolbarIcon: function () {
+    // The deleteSelectedRows action trigger should be the same than the 
toolbar button, so if this last one is overwritten,
+    // this delete rows logic should perform the same action than the toolbar 
button.
+    var grid = this,
+        isToolbarButtonFound = false,
+        toolbarButton, i;
+    if (grid.getSelectedRecords().length < 1) {
+      return false;
+    }
+    if (grid.view.toolBar && grid.view.toolBar.leftMembers && 
isc.OBToolbar.TYPE_DELETE) {
+      for (i = 0; i < grid.view.toolBar.leftMembers.length; i++) {
+        if (grid.view.toolBar.leftMembers[i].buttonType === 
isc.OBToolbar.TYPE_DELETE) {
+          isToolbarButtonFound = true;
+          toolbarButton = grid.view.toolBar.leftMembers[i];
+          if (!toolbarButton.disabled) {
+            toolbarButton.action();
+            return true;
+          }
+          break;
+        }
+      }
+    }
+    // But if the toolbar button is not found, do the default action
+    if (!isToolbarButtonFound) {
+      grid.view.deleteSelectedRows();
+      return true;
+    }
+    return false;
+  },
+
   // +++++++++++++++++++++++++++++ Record Selection Handling 
+++++++++++++++++++++++
   updateSelectedCountDisplay: function () {
     var selection = this.getSelection(),

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to