From b3a97d1a5e9bb92036627188d19eea1f96b43842 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 20 Jan 2012 17:46:23 -0500 Subject: [PATCH] org unit visibility testing For now there's no user-friendly on/off switch. The way to turn it off is not to put a "org_unit_getter" property in the storeArgs argument to openils.widget.AutoSuggest's constructor. Signed-off-by: Lebbeous Fogle-Weekley --- Open-ILS/web/js/dojo/openils/AutoSuggestStore.js | 17 ++++++++++------- Open-ILS/web/opac/skin/default/js/search_bar.js | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/AutoSuggestStore.js b/Open-ILS/web/js/dojo/openils/AutoSuggestStore.js index 5c93d1bb5c..5d65291493 100644 --- a/Open-ILS/web/js/dojo/openils/AutoSuggestStore.js +++ b/Open-ILS/web/js/dojo/openils/AutoSuggestStore.js @@ -24,6 +24,7 @@ if (!dojo._hasResource["openils.AutoSuggestStore"]) { "limit": 10, "last_fetch": null, + "org_unit_getter": null, "constructor": function(/* object */ args) { dojo.mixin(this, args); /* XXX very sloppy */ @@ -71,18 +72,20 @@ if (!dojo._hasResource["openils.AutoSuggestStore"]) { var limit = (!isNaN(req.count) && req.count != Infinity) ? req.count : this.limit; - if (!term || term.length < 1 || term == "*") - return null; - - if (term.match(/[^\s*]$/)) - term += " "; + if (!term || term.length < 1 || term == "*") return null; + if (term.match(/[^\s*]$/)) term += " "; term = term.replace(/\*$/, ""); - return "/opac/extras/autosuggest?" + [ + var params = [ "query=" + encodeURI(term), "search_class=" + this.type_selector.value, "limit=" + limit - ].join("&"); + ]; + + if (typeof this.org_unit_getter == "function") + params.push("org_unit=" + this.org_unit_getter()); + + return "/opac/extras/autosuggest?" + params.join("&"); }, /* *** Begin dojo.data.api.Read methods *** */ diff --git a/Open-ILS/web/opac/skin/default/js/search_bar.js b/Open-ILS/web/opac/skin/default/js/search_bar.js index 82e3700c0f..5f8cdb9eab 100644 --- a/Open-ILS/web/opac/skin/default/js/search_bar.js +++ b/Open-ILS/web/opac/skin/default/js/search_bar.js @@ -50,7 +50,10 @@ function updateSearchTypeSelector(id) { function autoSuggestInit() { var widg = new openils.widget.AutoSuggest( { - "storeArgs": {"type_selector": G.ui.searchbar.type_selector}, + "storeArgs": { + "type_selector": G.ui.searchbar.type_selector, + "org_unit_getter": depthSelGetNewLoc + }, "onChange": function(value) { if (typeof value.field == "number") updateSearchTypeSelector(value.field); -- 2.11.0