1) global flag for autosuggest on/off, opac-visiblity 2) don't hardcode as style
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 23 Jan 2012 21:57:25 +0000 (16:57 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 23 Jan 2012 22:29:51 +0000 (17:29 -0500)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib_autosuggest.sql
Open-ILS/web/opac/skin/default/js/search_bar.js

index ddb6b39..420ef9c 100644 (file)
@@ -9247,6 +9247,19 @@ INSERT INTO config.global_flag (name, label, enabled)
         FALSE
     );
 
+INSERT INTO config.global_flag (name, label, enabled)
+    VALUES (
+        'opac.use_autosuggest',
+        oils_i18n_gettext(
+            'opac.use_autosuggest',
+            'OPAC: Show auto-completing suggestions dialog under basic search box (put ''opac_visible'' into the value field to limit suggestions to OPAC-visible items)',
+            'cgf',
+            'label'
+        ),
+        FALSE
+    );
+
+
 INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
     VALUES (
         'history.circ.retention_age',
index e64f39f..96107b8 100644 (file)
@@ -2,6 +2,12 @@ BEGIN;
 
 SELECT evergreen.upgrade_deps_block_check('YYYY', :eg_version);
 
+INSERT INTO config.global_flag (label, name, enabled) VALUES (
+    'opac.use_autosuggest',
+    'OPAC: Show auto-completing suggestions dialog under basic search box (put ''opac_visible'' into the value field to limit suggestions to OPAC-visible items)',
+    FALSE
+);
+
 CREATE TABLE metabib.browse_entry (
     id BIGSERIAL PRIMARY KEY,
     value TEXT unique,
index 12f827d..9ab58b6 100644 (file)
@@ -13,6 +13,7 @@ G.evt.common.init.push(searchBarInit);
 var newSearchLocation; 
 var newSearchDepth = null;
 
+dojo.require("openils.Util");
 dojo.require("openils.widget.AutoSuggest");
 
 function updateSearchTypeSelector(id) {
@@ -48,11 +49,26 @@ function updateSearchTypeSelector(id) {
 }
 
 function autoSuggestInit() {
+    var global_flag = fieldmapper.standardRequest(
+        ["open-ils.fielder", "open-ils.fielder.cgf.atomic"], {
+            "query": {"name": "opac.use_autosuggest"},
+            "fields": ["enabled", "value"]
+        }
+    );
+
+    var org_unit_getter = null;
+
+    if (!global_flag || !openils.Util.isTrue(global_flag.enabled)) {
+        return;
+    } else if (global_flag.value && global_flag.value.match(/opac_visible/)) {
+        org_unit_getter = depthSelGetNewLoc;
+    }
+
     var widg = new openils.widget.AutoSuggest(
         {
             "storeArgs": {
                 "type_selector": G.ui.searchbar.type_selector,
-                "org_unit_getter": depthSelGetNewLoc
+                "org_unit_getter": org_unit_getter
             },
             "onChange": function(value) {
                 if (typeof value.field == "number")
@@ -62,7 +78,7 @@ function autoSuggestInit() {
                 if (event.charOrCode == dojo.keys.ENTER)
                     searchBarSubmit();
             },
-            "style": {"width": dojo.attr("search_box", "style").width},
+            "style": {"width": dojo.style("search_box", "width")},
             "value": ((getTerm() != null) ? getTerm() : "")
         }, "search_box"
     );