From 769c9c1868505ad4c88e29ecddc15f332ada496b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 25 Nov 2015 14:46:16 -0500 Subject: [PATCH] JBAS-1007 (KMAIN-1642) ACQ items navigation improvements This code is based on the original code at e595e444. 1. When drawing the lineitem copies page, select() the value in the Item Count Count text input so staff can more quickly modify the value. 2. After adding copies, focus the first owning lib selector. 3. When an owning lib selector is focused, pressing Enter causes focus to jump to the next lib selector in the list. Signed-off-by: Bill Erickson --- Open-ILS/web/js/ui/default/acq/common/li_table.js | 42 ++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index e4c6e74e22..438da0272b 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -2444,6 +2444,7 @@ function AcqLiTable() { this._drawCopies = function(li) { var self = this; + self.firstItemLibSelector = null; // this button sets the total number of copies for a given lineitem acqLitAddCopyCount.onClick = function() { @@ -2463,6 +2464,17 @@ function AcqLiTable() { acqLitCopyCountInput.attr('value', self.copyCount()+''); } } + + // KCLS -- after adding new copies, focus the library + // selector of the first copy in the list. Add the timeout + // so prevent focus shifting before the onKeyUp handler fires. + // Otherwise, onKeyUp is called on the lib selector instead + // of acqLitAddCopyCount, causing focus to jump to the + // second selector. + setTimeout(function() { + if (self.firstItemLibSelector) + self.firstItemLibSelector.focus(); + }, 100); } @@ -2475,6 +2487,13 @@ function AcqLiTable() { } else { self.addCopy(li); } + + // KCLS: select the Item Count value for easier modification. + setTimeout(function() { + var node = acqLitCopyCountInput + .domNode.getElementsByTagName('input')[0]; + if (node) node.select(); + }, 500); }; this.copyCount = function() { @@ -2559,7 +2578,7 @@ function AcqLiTable() { parentNode : dojo.query('[name='+field+']', row)[0], orgLimitPerms : ['CREATE_PICKLIST', 'CREATE_PURCHASE_ORDER'], readOnly : readOnly, - orgDefaultsToWs : true + //orgDefaultsToWs : true // KCLS wants empty lib selector }); widget.build( @@ -2586,6 +2605,27 @@ function AcqLiTable() { } } ); + + // KCLS --- + if (field == 'owning_lib') { + var nodeId = w.id.replace(/.*(\d+)$/,'$1'); + + // track the first library selector so we can + // focus it after generating new copies + if (nodeId == 1) self.firstItemLibSelector = w; + + // User pressing Enter on the ownling library + // selector causes focus to jump to the next + // owning library selector in the list of copies. + dojo.connect(w, 'onKeyUp', function(key) { + if (key.keyCode != 13) return // 13 = Enter + // ID's for like dijits increment by 1. + var nextId = w.id.replace( + /(.*)\d+$/, '$1' + (Number(nodeId) + 1)); + if (dijit.byId(nextId)) + dijit.byId(nextId).focus(); + }); + } } ); } -- 2.11.0