From: Kyle Huckins Date: Tue, 20 Sep 2016 21:12:23 +0000 (-0700) Subject: CAT-80 Set focus to distribution formula X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c695f7ae53837310a8693c97544e2d32b3950961;p=working%2FEvergreen.git CAT-80 Set focus to distribution formula Refactor focusCopyLibSelector to accept a boolean parameter and have the option to move foucs onto the distribution formula field instead of the first copy's owning library selector. Signed-off-by: Kyle Huckins --- 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 a3b63a8cd6..b41cc0f2c0 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 @@ -2532,17 +2532,30 @@ function AcqLiTable() { * handler fires. Otherwise, onKeyUp is called on the lib selector * instead of acqLitAddCopyCount, causing focus to jump to the second * selector. + * + * Takes a boolean to determine whether it'll use the original Evergreen + * behavior. True will bring it to the Distribution Formula selector, + * while False will retain the original behavior of setting focus to the + * first copy's owning library selector. + * */ - this.focusCopyLibSelector = function() { + this.focusCopyLibSelector = function(toDistribFormula) { setTimeout(function() { - var row = dojo.query('tr', self.copyTbody)[0]; - if (!row) return; + var row; + var selector; + if(toDistribFormula) { + row = dojo.query('div', 'acq-lit-distrib-formula-tbody')[0]; + if (row) selector = dojo.query('input', row)[0]; + } else { + row = dojo.query('tr', self.copyTbody)[0]; - // The first filteringtreeselect is our owning lib selector - // They are sequential, but don't necessarily start with _1, - // since rows can be arbitrarily removed. - var selector = dojo.query( - '[id^="openils_widget_FilteringTreeSelect_"]', row)[0]; + // The first filteringtreeselect is our owning lib selector + // They are sequential, but don't necessarily start with _1, + // since rows can be arbitrarily removed. + if (row) selector = dojo.query( + '[id^="openils_widget_FilteringTreeSelect_"]', row)[0]; + } + if (!row) return; if (selector) selector.focus(); }, 100); } @@ -2571,7 +2584,7 @@ function AcqLiTable() { // KCLS -- after adding or removing copies, focus the library // selector of the first copy in the list. - self.focusCopyLibSelector(); + self.focusCopyLibSelector(true); } @@ -2979,7 +2992,7 @@ function AcqLiTable() { if(copy.isnew()) delete this.copyCache[copy.id()]; this.copyTbody.removeChild(row); - this.focusCopyLibSelector(); + this.focusCopyLibSelector(true); } this._virtDfaCountsAsList = function() {