Acq lineitem batch updater - really fix dist formula interface acq-batch-updater
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 26 Feb 2013 17:00:03 +0000 (12:00 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 26 Feb 2013 17:00:03 +0000 (12:00 -0500)
the .focus() trick wasn't actually fixing anything

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js

index d20c81e..a2d5eec 100644 (file)
@@ -12,7 +12,8 @@ var formCache = {};
 var formula, entryTbody, entryTemplate, dndSource;
 var virtualId = -1;
 var pcrud;
-
+var _collection_code_textboxes = [];
+var _collection_code_kludge_active = false;
 
 function gridDataLoader() {
     fListGrid.resetStore();
@@ -159,10 +160,9 @@ function addEntry(entry) {
                 dijitArgs : (field == 'item_count') ? {min:1, places:0} : null
             }).build(
                 function(w, ww) {
-                    /* kludge for glitchy textbox */
                     if (field == "collection_code") {
-                        w.focus();
-                        byName(row, "owning_lib").focus();
+                        /* kludge for glitchy textbox */
+                        _collection_code_textboxes.push(w);
                     }
                     dojo.connect(w, 'onChange', 
                         function(newVal) {
@@ -174,6 +174,35 @@ function addEntry(entry) {
             );
         }
     );
+
+    /* For some reason (bug) the dndSource intercepts onMouseDown events
+     * that should hit dijit textboxes in our table thingy. Other dijits
+     * (buttons, filteringselects, etc) seem not to be affected.  This
+     * workaround deals with the only textboxes we have for now: the ones
+     * for the collection_code field. */
+    if (!_collection_code_kludge_active) {
+        _collection_code_kludge_active = true;
+        var original = dojo.hitch(dndSource, dndSource.onMouseDown);
+        dndSource.onMouseDown = function(e) {
+            var hits = _collection_code_textboxes.filter(
+                function(w) {
+                    var c = dojo.coords(w.domNode);
+                    if (e.clientX >= c.x && e.clientX < c.x + c.w) {
+                        if (e.clientY >= c.y && e.clientY < c.y + c.h) {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+            );
+
+            if (hits.length) {
+                hits[0].focus();
+            } else {
+                original(e);
+            }
+        };
+    }
 }
 
 function saveFormula() {