From: Thomas Berezansky Date: Thu, 29 Mar 2012 19:37:07 +0000 (-0400) Subject: Coded Value Maps Opac Visible/Search Labels X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3caf5a7f4e279219557d93ae231b228e844b5951;p=contrib%2FConifer.git Coded Value Maps Opac Visible/Search Labels Add two new fields to Coded Value Maps: 1 - Opac Visible, for "does this show up in opac limiter boxes" 2 - Search Label, for "what does this get called for those boxes" Intended use cases include: Re-labeling MARC fields without changing the base MARC information, say because you don't expect patrons to understand "Projected Medium". Hiding things that don't apply, say the vast majority of language limiters, without needing to delete rows. I also hooked it up in JSPac, because it was easy to do so. Signed-off-by: Thomas Berezansky Signed-off-by: Ben Shum --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 10b58372de..0da0727a8a 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -788,6 +788,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 3fd9983c43..6031eac5dd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -70,12 +70,18 @@ sub init_ro_object_cache { # search for objects of class $hint where field=value $cache{search}{$hint} = {}; $ro_object_subs->{$search_key} = sub { - my ($field, $val) = @_; + my ($field, $val, $filterfield, $filterval) = @_; my $method = "search_$eclass"; + my $cacheval = $val; + my $search_obj = {$field => $val}; + if($filterfield) { + $search_obj->{$filterfield} = $filterval; + $cacheval .= ':' . $filterfield . ':' . $filterval; + } $cache{search}{$hint}{$field} = {} unless $cache{search}{$hint}{$field}; - $cache{search}{$hint}{$field}{$val} = $e->$method({$field => $val}) - unless $cache{search}{$hint}{$field}{$val}; - return $cache{search}{$hint}{$field}{$val}; + $cache{search}{$hint}{$field}{$cacheval} = $e->$method($search_obj) + unless $cache{search}{$hint}{$field}{$cacheval}; + return $cache{search}{$hint}{$field}{$cacheval}; }; } diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 734f3a972c..af24ba4ec9 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -737,11 +737,13 @@ CREATE TABLE config.record_attr_index_norm_map ( ); CREATE TABLE config.coded_value_map ( - id SERIAL PRIMARY KEY, - ctype TEXT NOT NULL REFERENCES config.record_attr_definition (name) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, - code TEXT NOT NULL, - value TEXT NOT NULL, - description TEXT + id SERIAL PRIMARY KEY, + ctype TEXT NOT NULL REFERENCES config.record_attr_definition (name) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + code TEXT NOT NULL, + value TEXT NOT NULL, + description TEXT, + opac_visible BOOL NOT NULL DEFAULT TRUE, -- For TPac selectors + search_label TEXT ); CREATE VIEW config.language_map AS SELECT code, value FROM config.coded_value_map WHERE ctype = 'item_lang'; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.tpac_value_maps.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.tpac_value_maps.sql new file mode 100644 index 0000000000..4e409ece67 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.tpac_value_maps.sql @@ -0,0 +1,3 @@ +ALTER TABLE config.coded_value_map + ADD COLUMN opac_visible BOOL NOT NULL DEFAULT TRUE, + ADD COLUMN search_label TEXT; diff --git a/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 b/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 index b49804fb7a..735436828d 100644 --- a/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 +++ b/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 @@ -17,7 +17,7 @@ 0; LAST; END; END; name = name || "fi:" _ attr_class; @@ -25,7 +25,7 @@ # leverage TT's array.sort('') behavior sorter = []; FOR o IN all_values; - sorter.push({code => o.code, value => o.value}); + sorter.push({code => o.code, value => (o.search_label ? o.search_label : o.value)}); END; FOR o IN sorter.sort('value') %] diff --git a/Open-ILS/web/opac/skin/default/js/adv_global.js b/Open-ILS/web/opac/skin/default/js/adv_global.js index 7422e90618..de2987604b 100644 --- a/Open-ILS/web/opac/skin/default/js/adv_global.js +++ b/Open-ILS/web/opac/skin/default/js/adv_global.js @@ -16,7 +16,7 @@ function advgInit() { var ctypes = ["bib_level", "item_form", "item_type", "audience", "lit_form"]; - var req = new Request('open-ils.fielder:open-ils.fielder.ccvm.atomic', {"cache":1,"query":{"ctype":ctypes}}); + var req = new Request('open-ils.fielder:open-ils.fielder.ccvm.atomic', {"cache":1,"query":{"ctype":ctypes, "opac_visible":"t"}}); req.callback(advDrawBibExtras); req.request.ctypes = ctypes; req.send(); @@ -156,13 +156,13 @@ function advDrawBibExtras(r) { var ctypeData = dojo.filter(data, function(item) { return item.ctype == ctype } ); ctypeData = ctypeData.sort( function(a,b) { /* sort alphabetically */ - return (a.value < b.value) ? -1 : 1; + return ((a.search_label ? a.search_label : a.value) < (b.search_label ? b.search_label : b.value)) ? -1 : 1; } ); dojo.forEach(ctypeData, function(thing) { - var opt = insertSelectorVal(sel, -1, thing.value, thing.code); - opt.setAttribute('title', thing.value); + var opt = insertSelectorVal(sel, -1, (thing.search_label ? thing.search_label : thing.value), thing.code); + opt.setAttribute('title', (thing.search_label ? thing.search_label : thing.value)); } ); }