LP#1053397 TPAC show all MR formats in results list
authorBill Erickson <berick@esilibrary.com>
Thu, 6 Feb 2014 18:14:45 +0000 (13:14 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 10 Feb 2014 16:02:28 +0000 (11:02 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

index 78898fb..589a2c1 100644 (file)
         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;
 
 
         # "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 = [];
index b72e638..42497a0 100644 (file)
@@ -112,7 +112,12 @@ END;
                                                     </div>
                                                     <div id='bib_format' class='result_table_title_cell'>
                                                     [%- IF attrs.format_label; %]
-                                                        <img title="[% attrs.format_label | html %]" alt="[% attrs.format_label | html %]" src="[% attrs.format_icon %]" /> [% attrs.format_label; %]
+                                                        [% FOR format IN attrs.all_formats %]
+                                                            <img title="[% format.label | html %]" 
+                                                                alt="[% format.label | html %]" 
+                                                                src="[% format.icon %]" /> 
+                                                            [% format.label | html %]
+                                                        [% END %]
                                                     [%- END %]
                                                     [%- UNLESS CGI.param('detail_record_view')
                                                             OR (show_more_details.default == 'true'