From 4d0050739339b0b26dc85b982d068e8e225170a9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 31 Jan 2012 12:17:20 -0500 Subject: [PATCH] ACQ+Vandelay disallow match_set change on selected queue Consistent with Vandelay, if a queue is selected, show the linked match_set and disable the match_set selector. Existing queues are already linked to a match set, so allowing the user to select one has no effect, which is confusing. Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- Open-ILS/web/js/ui/default/acq/common/vlagent.js | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Open-ILS/web/js/ui/default/acq/common/vlagent.js b/Open-ILS/web/js/ui/default/acq/common/vlagent.js index 1af1f771af..e7c5b054ac 100644 --- a/Open-ILS/web/js/ui/default/acq/common/vlagent.js +++ b/Open-ILS/web/js/ui/default/acq/common/vlagent.js @@ -36,10 +36,12 @@ function VLAgent(args) { parentNode : dojo.byId('acq_vl:' + widg.key) }).build(function(dijit) { widg.dijit = dijit; + self.attachOnChange(widg); }); } else { // bools widg.dijit = dijit.byId('acq_vl:' + widg.key); + self.attachOnChange(widg); } } ); @@ -49,6 +51,62 @@ function VLAgent(args) { this.loaded = true; } + this.attachOnChange = function(widg) { + var self = this; + var qInputChange; + + var qSelChange = function(val) { + // user selected a queue from the selector; clear the text input + // and set the item import profile already defined for the queue + + var qInput = self.getDijit('queue_name'); + var matchSetSelector = self.getDijit('match_set'); + var qSelector = self.getDijit('existing_queue'); + + if(val) { + qSelector.store.fetch({ + query : {id : val+''}, + onComplete : function(items) { + matchSetSelector.attr('value', items[0].match_set[0] || ''); + matchSetSelector.attr('disabled', true); + } + }); + } else { + matchSetSelector.attr('value', ''); + matchSetSelector.attr('disabled', false); + } + + // detach and reattach to avoid onchange firing while when we clear + dojo.disconnect(qInput._onchange); + qInput.attr('value', ''); + qInput._onchange = dojo.connect(qInput, 'onChange', qInputChange); + } + + qInputChange = function(val) { + // TODO: user may enter the name of an existing queue. + // Detect this and disable/update match_set accordingly + self.getDijit('match_set').attr('disabled', false); + var qSelector = self.getDijit('existing_queue'); + dojo.disconnect(qSelector._onchange); + qSelector.attr('value', ''); + qSelector._onchange = dojo.connect(qSelector, 'onChange', qSelChange); + } + + if (widg.key == 'existing_queue') { + var qSelector = self.getDijit('existing_queue'); + qSelector._onchange = dojo.connect(qSelector, 'onChange', qSelChange); + } else if(widg.key == 'queue_name') { + var qInput = self.getDijit('queue_name'); + qInput._onchange = dojo.connect(qInput, 'onChange', qInputChange); + } + } + + this.getDijit = function(key) { + return this.widgets.filter( + function(w) {return (w.key == key)} + )[0].dijit; + } + this.values = function() { var values = {}; dojo.forEach(this.widgets, -- 2.11.0