details: https://code.openbravo.com/erp/devel/pi/rev/daffb319b79d changeset: 28178:daffb319b79d user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Mon Jan 11 12:33:11 2016 +0100 summary: fixes issue 27773: Not possible to work with keyboard shortcuts in Add Details
Now the OBPickAndExecuteGrid implements the ability to capture keyboard shortcuts and execute the corresponding actions. In addition, there was a problem with shortcuts having a parameter window opened: it was possible to execute shortcuts of the 'parent' window. This problem has been solved too by disabling the shortcuts of the parent view after opening a pick and execute view. diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js | 29 +++++- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js | 49 +++++++++- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js | 5 +- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js | 4 +- 4 files changed, 79 insertions(+), 8 deletions(-) diffs (198 lines): diff -r d37423058aab -r daffb319b79d modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js Mon Jan 04 19:14:21 2016 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js Mon Jan 11 12:33:11 2016 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2012-2015 Openbravo SLU + * All portions are Copyright (C) 2012-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -339,6 +339,7 @@ this.closeClick = function () { return true; }; // To avoid loop when "Super call" + this.enableParentViewShortcuts(); // restore active view shortcuts before closing if (this.isExpandedRecord) { this.callerField.grid.collapseRecord(this.callerField.record); } else { @@ -360,6 +361,8 @@ isc.addProperties(context || {}, this.callerField.view.getContextInfo(true /*excludeGrids*/ )); } + this.disableParentViewShortcuts(); + OB.RemoteCallManager.call('org.openbravo.client.application.process.DefaultsProcessActionHandler', context, { processId: this.processId, windowId: this.windowId @@ -473,6 +476,7 @@ this.closeClick = function () { return true; }; // To avoid loop when "Super call" + this.enableParentViewShortcuts(); // restore active view shortcuts before closing if (this.isExpandedRecord) { this.callerField.grid.collapseRecord(this.callerField.record); } else { @@ -766,5 +770,28 @@ } } return true; + }, + + getParentActiveView: function () { + if (this.buttonOwnerView && this.buttonOwnerView.standardWindow) { + return this.buttonOwnerView.standardWindow.activeView; + } + return null; + }, + + disableParentViewShortcuts: function () { + var activeView = this.getParentActiveView(); + if (activeView && activeView.viewGrid && activeView.toolBar) { + activeView.viewGrid.disableShortcuts(); + activeView.toolBar.disableShortcuts(); + } + }, + + enableParentViewShortcuts: function () { + var activeView = this.getParentActiveView(); + if (activeView && activeView.viewGrid && activeView.toolBar) { + activeView.viewGrid.enableShortcuts(); + activeView.toolBar.enableShortcuts(); + } } }); \ No newline at end of file diff -r d37423058aab -r daffb319b79d modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js Mon Jan 04 19:14:21 2016 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js Mon Jan 11 12:33:11 2016 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2011-2015 Openbravo SLU + * All portions are Copyright (C) 2011-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -101,7 +101,7 @@ len = orig.length, crit, i; - if (criteria._OrExpression) { + if (criteria && criteria._OrExpression) { for (i = 0; i < len; i++) { if (orig[i].fieldName && orig[i].fieldName === 'id') { continue; @@ -460,7 +460,7 @@ if (!found) { - if (!criteria) { + if (!criteria || isc.isA.emptyObject(criteria)) { criteria = { _constructor: 'AdvancedCriteria', operator: 'and', @@ -481,7 +481,7 @@ if (this._cleaningFilter) { // Always refresh when cleaning the filter - if (!criteria) { + if (!criteria || isc.isA.emptyObject(criteria)) { criteria = { _constructor: 'AdvancedCriteria', operator: 'and', @@ -951,6 +951,47 @@ refreshGrid: function () { // fetch the data with the current criteria and context info this.filterData(this.getCriteria(), null, this.getContextInfo()); + }, + + bodyKeyPress: function (event, eventInfo) { + var response = OB.KeyboardManager.Shortcuts.monitor('OBPickAndExecuteGrid.body', this); + if (response !== false) { + response = this.Super('bodyKeyPress', arguments); + } + return response; + }, + + enableShortcuts: function () { + var ksAction_PickAndExecuteNewRow, ksAction_PickAndExecuteEliminate; + + ksAction_PickAndExecuteNewRow = function (caller) { + var pickAndEditGrid; + if (caller && caller.grid && caller.grid.getPrototype().Class === 'OBPickAndExecuteGrid') { + pickAndEditGrid = caller.grid; + if (pickAndEditGrid.contentView && pickAndEditGrid.viewProperties && pickAndEditGrid.viewProperties.allowAdd) { + pickAndEditGrid.contentView.addNewButton.action(); + } + } + return false; //To avoid keyboard shortcut propagation + }; + + ksAction_PickAndExecuteEliminate = function (caller) { + var selectedRecords, i; + if (caller && caller.getPrototype().Class === 'OBPickAndExecuteGrid' && caller.getSelectedRecords() && caller.viewProperties && caller.viewProperties.allowDelete) { + selectedRecords = caller.getSelectedRecords(); + for (i = 0; i < selectedRecords.length; i++) { + caller.removeRecord(caller.getRecordIndex(selectedRecords[i])); + } + } + return false; //To avoid keyboard shortcut propagation + }; + + // The Ctrl + i is being always captured at Canvas level, for this reason we register the 'new record' event at this very same level + OB.KeyboardManager.Shortcuts.set('ToolBar_NewRow', ['Canvas'], ksAction_PickAndExecuteNewRow); + OB.KeyboardManager.Shortcuts.set('ToolBar_Eliminate', ['OBPickAndExecuteGrid.body'], ksAction_PickAndExecuteEliminate); + OB.KeyboardManager.Shortcuts.set('ViewGrid_DeleteSelectedRecords', ['OBPickAndExecuteGrid.body'], ksAction_PickAndExecuteEliminate); + + this.Super('enableShortcuts', arguments); } }); \ No newline at end of file diff -r d37423058aab -r daffb319b79d modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js Mon Jan 04 19:14:21 2016 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js Mon Jan 11 12:33:11 2016 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2011-2014 Openbravo SLU + * All portions are Copyright (C) 2011-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -178,6 +178,9 @@ }, formatEditorValue: function (value, record, rowNum, colNum, grid) { return this.formatCellValue(arguments); + }, + filterEditorProperties: { + canFocus: false } }); }, diff -r d37423058aab -r daffb319b79d modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js Mon Jan 04 19:14:21 2016 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js Mon Jan 11 12:33:11 2016 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2010-2013 Openbravo SLU + * All portions are Copyright (C) 2010-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -419,7 +419,7 @@ if (isc.Event.getKey() === 'Space') { OB.KeyboardManager.Shortcuts.isSpacePressed = true; } - response = OB.KeyboardManager.Shortcuts.monitor('Canvas'); + response = OB.KeyboardManager.Shortcuts.monitor('Canvas', this); if (response !== false) { // To ensure that if a previous keyDown was set in the Canvas it is executed if the action KeyboardManager.action should be propagated response = OB.Utilities.callAction(actionObject); } ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits