From 3caf5a7f4e279219557d93ae231b228e844b5951 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky <tsbere@mvlc.org> Date: Thu, 29 Mar 2012 15:37:07 -0400 Subject: [PATCH] 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 <tsbere@mvlc.org> Signed-off-by: Ben Shum <bshum@biblio.org> --- Open-ILS/examples/fm_IDL.xml | 2 ++ Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 14 ++++++++++---- Open-ILS/src/sql/Pg/002.schema.config.sql | 12 +++++++----- Open-ILS/src/sql/Pg/upgrade/XXXX.tpac_value_maps.sql | 3 +++ .../src/templates/conify/global/config/coded_value_map.tt2 | 2 +- Open-ILS/src/templates/opac/parts/coded_value_selector.tt2 | 4 ++-- Open-ILS/web/opac/skin/default/js/adv_global.js | 8 ++++---- 7 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.tpac_value_maps.sql 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 <field reporter:label="Code" name="code" reporter:datatype="text" oils_obj:required="true"/> <field reporter:label="Value" name="value" reporter:datatype="text" oils_obj:required="true"/> <field reporter:label="Description" name="description" reporter:datatype="text"/> + <field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/> + <field reporter:label="Search Label" name="search_label" reporter:datatype="text" oils_persist:i18n="true"/> </fields> <links> <link field="ctype" reltype="has_a" key="name" map="" class="crad"/> 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 @@ <table jsId="ccvmGrid" autoHeight='true' dojoType="openils.widget.AutoGrid" - fieldOrder="['ctype', 'code', 'value', 'description']" + fieldOrder="['ctype', 'code', 'value', 'description', 'opac_visible', 'search_label']" query="{code: '*'}" defaultCellWidth='"25%"' fmClass='ccvm' diff --git a/Open-ILS/src/templates/opac/parts/coded_value_selector.tt2 b/Open-ILS/src/templates/opac/parts/coded_value_selector.tt2 index 0016b7a1a9..acb464e38e 100644 --- a/Open-ILS/src/templates/opac/parts/coded_value_selector.tt2 +++ b/Open-ILS/src/templates/opac/parts/coded_value_selector.tt2 @@ -7,7 +7,7 @@ all_values = []; attr_class = ''; FOR attr_class IN attr; - all_values = ctx.search_ccvm('ctype', attr_class); + all_values = ctx.search_ccvm('ctype', attr_class, 'opac_visible', 't'); IF all_values.size > 0; LAST; END; END; name = name || "fi:" _ attr_class; @@ -25,7 +25,7 @@ # leverage TT's array.sort('<hashkey>') 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') %] <option value='[% o.code | uri %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option> 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)); } ); } -- 2.11.0