org unit visibility testing
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 20 Jan 2012 22:46:23 +0000 (17:46 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 23 Jan 2012 17:27:00 +0000 (12:27 -0500)
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 <lebbeous@esilibrary.com>
Open-ILS/web/js/dojo/openils/AutoSuggestStore.js
Open-ILS/web/opac/skin/default/js/search_bar.js

index 5c93d1b..5d65291 100644 (file)
@@ -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 *** */
index 82e3700..5f8cdb9 100644 (file)
@@ -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);