From e51477e408b1c5f818b967f809f1fc328201d2cb Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 28 Jun 2011 23:15:52 -0400 Subject: [PATCH] Improve copy display in search results 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 --- .../web/templates/default/opac/parts/misc_util.tt2 | 20 ++++++------ .../templates/default/opac/parts/result/table.tt2 | 37 +++++++++++++++------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 index 04add44516..5d4249e469 100644 --- a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 @@ -30,17 +30,16 @@ 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'); @@ -67,15 +66,16 @@ 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; diff --git a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 index efb50f7bef..964312ac65 100644 --- a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 @@ -6,6 +6,7 @@ result_count = ctx.result_start; %] +
[% BLOCK results_count_header %]
@@ -129,16 +130,6 @@ [% args.phys_desc %] - - [% FOR copy IN args.holdings %] - - - [% l('Call number:') %] - - [% copy.label _ ' ' _ copy.location _ ' ' _ copy.library _ ' ' _ copy.status %] - - [% END %] - [% FOR uri IN args.uris%] @@ -147,8 +138,30 @@ [% uri.link %][% ' - ' _ uri.note IF uri.note %] [% END %] - - + [% IF args.holdings.size > 0 %] + + + + + + + + + + + [% FOR copy IN args.holdings %] + + + + + + + [% END %] + +
[% l('Library') %][% l('Shelving location') %][% l('Call number') %][% l('Status') %]
[% copy.library %][% copy.location %][% copy.label %][% copy.status %]
+ + + [% END %]
[% l('[_1] of [quant,_2,copy,copies] available', -- 2.11.0