From: Bill Erickson Date: Wed, 1 Feb 2012 14:12:23 +0000 (-0500) Subject: ACQ+Vandelay detect existing queue with same name X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=21af7aa110578896b9c40e10b8c9a4f86cf52e95;p=evergreen%2Fjoelewis.git ACQ+Vandelay detect existing queue with same name Within the acq/vandelay agent, detect when a user has entered the name of one of their existing queues. When detected, update the queue selector to match the found queue (which updates the linked match set and clears the queue selector input). Otherwise, users may not realize they are adding items to an existing queue (with a pre-linked match set). Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- 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 8444b9cfc7..7e307c6f42 100644 --- a/Open-ILS/web/js/ui/default/acq/common/vlagent.js +++ b/Open-ILS/web/js/ui/default/acq/common/vlagent.js @@ -84,13 +84,33 @@ function VLAgent(args) { } 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); + var matchSetSelector = self.getDijit('match_set'); + var foundMatch = false; + + if (val) { + + // if the user entered the name of an existing queue, update the + // queue selector to match the value (and clear the text input + // via qselector onchange) + qSelector.store.fetch({ + query:{name:val}, + onComplete:function(items) { + if(items.length == 0) return; + var item = items[0]; + qSelector.attr('value', item.id); + foundMatch = true; + } + }); + } + + if (!foundMatch) { + self.getDijit('match_set').attr('disabled', false); + dojo.disconnect(qSelector._onchange); + qSelector.attr('value', ''); + qSelector._onchange = dojo.connect(qSelector, 'onChange', qSelChange); + } } if (widg.key == 'existing_queue') { @@ -103,9 +123,7 @@ function VLAgent(args) { } this.getDijit = function(key) { - return this.widgets.filter( - function(w) {return (w.key == key)} - )[0].dijit; + return this.widgets.filter(function(w) {return (w.key == key)})[0].dijit; } this.values = function() {