Improve copy display in search results
authorDan Scott <dan@coffeecode.net>
Wed, 29 Jun 2011 03:15:52 +0000 (23:15 -0400)
committerDan Scott <dan@coffeecode.net>
Wed, 29 Jun 2011 03:30:50 +0000 (23:30 -0400)
Even though we were trying to root our findnodes() call at a specific
point in the DOM, the XPath was retrieving all volume elements in the
entire DOM and we were therefore getting duplicate items listed in the
search results. Accordingly, use the volume ID to root the search to the
specific volume.

Also, offer designers a bit more of an opportunity to style the holdings
by placing them in a table as well. Bonus points for using thead/th, eh?

Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/web/templates/default/opac/parts/misc_util.tt2
Open-ILS/web/templates/default/opac/parts/result/table.tt2

index 04add44..5d4249e 100644 (file)
         args.uris = [];
 
         # URI info is in volumes/volume/uris/volume, instead of uri element
-        i = 0;
         FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
-            i = i + 1;
 
             # Check volume visibility - could push this into XPath
             vol.label = volume.getAttribute('label');
+            vol.id = volume.getAttribute('id');
             NEXT IF volume.getAttribute('opac_visible') == 'false';
             NEXT IF volume.getAttribute('deleted') == 'true';
 
             IF vol.label == '##URI##';
-                FOR uri IN xml.findnodes('//*[local-name()="uris"]/*[local-name()="volume"]', volume);
+                FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="volume"]');
                     res.href = uri.getAttribute('href');
                     res.link = uri.getAttribute('label');
                     res.note = uri.getAttribute('use_restriction');
@@ -48,7 +47,7 @@
                 END;
                 NEXT;
             ELSE;
-                copies = xml.findnodes('//*[local-name()="copies"]/*[local-name()="copy"]', volume);
+                copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
                 FOR copy IN copies;
                     # Check copy visibility
                     cp.deleted = copy.getAttribute('deleted');    
 
                     NEXT IF cp.visible == 'false';
                     
-                    loc = xml.findnodes('//*[local-name()="location"]', copy);
-                    circlib = xml.findnodes('//*[local-name()="circlib"]', copy);
-                    status = xml.findnodes('//*[local-name()="status"]', copy);
+                    loc = copy.findnodes('./*[local-name()="location"]');
+                    circlib = copy.findnodes('./*[local-name()="circlib"]');
+                    status = copy.findnodes('./*[local-name()="status"]');
 
                     holding = {
                         label => vol.label,
-                        location => loc.0.textContent,
-                        library => circlib.0.textContent,
-                        status => status.0.textContent
+                        location => loc.textContent,
+                        library => circlib.textContent,
+                        status => status.textContent
+                        barcode => copy.getAttribute('barcode')
                     };
                     args.holdings.push(holding);
                 END;
index efb50f7..964312a 100644 (file)
@@ -6,6 +6,7 @@
 
     result_count = ctx.result_start;
 %]
+
 <div style="height: 10px;"></div>
 [% BLOCK results_count_header %]
 <div class="results_header_nav1">
                                                                 [% args.phys_desc %]
                                                             </td>
                                                         </tr>
-
-                                                        [% FOR copy IN args.holdings %]
-                                                        <tr name='bib_cn_list' class='result_table_title_cell'>
-                                                            <td valign='top'>
-                                                                <strong>[% l('Call number:') %]</strong>
-                                                            </td>
-                                                            <td>[% copy.label _ ' ' _ copy.location _ ' ' _ copy.library _ ' ' _ copy.status %]</td>
-                                                        </tr>
-                                                        [% END %]
-
                                                         [% FOR uri IN args.uris%]
                                                         <tr name='bib_uri_list' class='result_table_title_cell'>
                                                             <td valign='top'>
                                                             <td><a href="[% uri.href %]">[% uri.link %]</a>[% ' - ' _ uri.note IF uri.note %]</td>
                                                         </tr>
                                                         [% END %]
-
-
+                                                        [% IF args.holdings.size > 0 %]
+                                                        <tr name='bib_cn_list' class='result_table_title_cell'>
+                                                            <td colspan='2'>
+                                                                <table class='result_holdings_table'>
+                                                                    <thead><tr>
+                                                                        <th>[% l('Library') %]</th>
+                                                                        <th>[% l('Shelving location') %]</th>
+                                                                        <th>[% l('Call number') %]</th>
+                                                                        <th>[% l('Status') %]</th>
+                                                                    </tr></thead>
+                                                                    <tbody>
+                                                            [% FOR copy IN args.holdings %]
+                                                                    <tr>
+                                                                        <td>[% copy.library %]</td>
+                                                                        <td>[% copy.location %]</td>
+                                                                        <td>[% copy.label %]</td>
+                                                                        <td>[% copy.status %]</td>
+                                                                    </tr>
+                                                            [% END %]
+                                                                    </tbody>
+                                                                </table>
+                                                            </td>
+                                                        </tr>
+                                                        [% END %]
                                                     </table>
                                                     <div>
                                                         [% l('[_1] of [quant,_2,copy,copies] available',