LP#1053397 MR holds displays selected formats
authorBill Erickson <berick@esilibrary.com>
Thu, 20 Feb 2014 19:48:53 +0000 (14:48 -0500)
committerDan Wells <dbw2@calvin.edu>
Fri, 21 Feb 2014 20:38:55 +0000 (15:38 -0500)
In a patron's holds list, only show formats in the format column
matching the patron's selected hold formats.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/templates/opac/myopac/holds.tt2
Open-ILS/src/templates/opac/parts/misc_util.tt2

index 0a7b04a..b08d230 100644 (file)
                     </td>
                     <td>
                         <div class="format_icon">
-                            [% IF attrs.all_formats.size %]
-                                [% FOR format IN attrs.all_formats %]
-                                <img title="[% format.label | html %]" alt="[% format.label | html %]" src="[% format.icon %]" />
-                                [% END %]
+                          [% 
+                            formats = attrs.all_formats.size;
+                            IF ahr.hold_type == 'M';
+                              # only show selected formats for metarecords
+                              formats = [];
+                              FOR ccvm IN hold.metarecord_selected_filters.icons;
+                                format = {};
+                                format.icon = PROCESS get_ccvm_icon id=ccvm.id search_label=1;
+                                format.label = PROCESS get_ccvm_label id=ccvm.id search_label=1;
+                                formats.push(format);
+                              END;
+                            END;
+                            FOR format IN formats 
+                          %]
+                            <img title="[% format.label | html %]" 
+                              alt="[% format.label | html %]" src="[% format.icon %]" />
                             [% END %]
                         </div>
                     </td>
index 589a2c1..c003c15 100644 (file)
         END;
     END;
 
+    BLOCK get_ccvm_icon;
+        ccvm = ctx.get_ccvm(id); # caches internally
+        label = PROCESS get_ccvm_label id=id search_label=search_label;
+        ctx.media_prefix _ '/images/format_icons/' _ ccvm.ctype _ '/' _ ccvm.code _ '.png';
+    END;
+
+
     # Extract MARC fields from XML
     #   get_marc_attrs( { marc_xml => doc } )
     BLOCK get_marc_attrs;
         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});
+                format = {};
+                format.icon = PROCESS get_ccvm_icon 
+                    id=node.getAttribute('cvmid') search_label=1;
+                format.label = PROCESS get_ccvm_label 
+                    id=node.getAttribute('cvmid') search_label=1;
+                format.itemtype = schema_typemap.$type || 'CreativeWork';
+
+                args.all_formats.push(format); # metarecords want all formats
+
                 IF !args.format_label;
                     # use the first format as the default
-                    args.format_label = label; 
-                    args.schema.itemtype = itemtype;
-                    args.format_icon = icon;
+                    args.format_label = format.label; 
+                    args.schema.itemtype = format.itemtype;
+                    args.format_icon = format.icon;
                 END;
             END;
         END;