From efa50bd70b16ffa58fce8b4ee00e3222caa330eb Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Tue, 26 Feb 2013 12:00:03 -0500 Subject: [PATCH] Acq lineitem batch updater - really fix dist formula interface the .focus() trick wasn't actually fixing anything Signed-off-by: Lebbeous Fogle-Weekley --- .../conify/global/acq/distribution_formula.js | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js b/Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js index d20c81e316..a2d5eece93 100644 --- a/Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js +++ b/Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js @@ -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() { -- 2.11.0