CAT-80 Set focus to distribution formula
authorKyle Huckins <khuckins@catalystdevworks.com>
Tue, 20 Sep 2016 21:12:23 +0000 (14:12 -0700)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
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 <khuckins@catalystdevworks.com>
Open-ILS/web/js/ui/default/acq/common/li_table.js

index a3b63a8..b41cc0f 100644 (file)
@@ -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() {