From cd7929e7f5949c4a059dd4c6362de38b5811487d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 6 Feb 2014 13:14:45 -0500 Subject: [PATCH] LP#1053397 TPAC show all MR formats in results list Signed-off-by: Bill Erickson --- Open-ILS/src/templates/opac/parts/misc_util.tt2 | 41 +++++++++++----------- Open-ILS/src/templates/opac/parts/result/table.tt2 | 7 +++- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index 78898fb0fa..589a2c16b1 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -79,18 +79,12 @@ END; END; - # Get CCVM labels BLOCK get_ccvm_label; - IF !ctx.ccvm_cache.$id; - fetch_ccvm = ctx.search_ccvm('id', id); - IF fetch_ccvm; - ctx.ccvm_cache.$id = fetch_ccvm.0; - END; - END; - IF search_label and ctx.ccvm_cache.$id.search_label; - ctx.ccvm_cache.$id.search_label; + ccvm = ctx.get_ccvm(id); # caches internally + IF search_label and ccvm.search_label; + ccvm.search_label; ELSE; - ctx.ccvm_cache.$id.value; + ccvm.$id.value; END; END; @@ -440,17 +434,24 @@ # "mattype" == "custom marc format specifier" icon_style = ctx.get_cgf('opac.icon_attr').value || 'item_type'; - node = xml.findnodes( - '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]'); - IF node AND node.textContent; - type = node.textContent; - args.format_label = PROCESS get_ccvm_label id=node.getAttribute('cvmid') search_label=1; - IF !args.format_label; - args.format_label = node.getAttribute('coded-value'); + formats_xpath = '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]'; + + args.all_formats = []; + FOR node IN xml.findnodes(formats_xpath); + IF node AND node.textContent; + type = node.textContent; + label = PROCESS get_ccvm_label id=node.getAttribute('cvmid') search_label=1; + itemtype = schema_typemap.$type || 'CreativeWork'; + icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ type _ '.png'; + # collect all formats for metarecord support + args.all_formats.push({label => label, icon => icon, itemtype => itemtype}); + IF !args.format_label; + # use the first format as the default + args.format_label = label; + args.schema.itemtype = itemtype; + args.format_icon = icon; + END; END; - args.schema.itemtype = schema_typemap.$type || 'CreativeWork'; - args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ type _ '.png'; - LAST; END; args.bibid = []; diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2 index b72e63850f..42497a09a0 100644 --- a/Open-ILS/src/templates/opac/parts/result/table.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/table.tt2 @@ -112,7 +112,12 @@ END;
[%- IF attrs.format_label; %] - [% attrs.format_label | html %] [% attrs.format_label; %] + [% FOR format IN attrs.all_formats %] + [% format.label | html %] + [% format.label | html %] + [% END %] [%- END %] [%- UNLESS CGI.param('detail_record_view') OR (show_more_details.default == 'true' -- 2.11.0