From eae9a5af3a7b0d35b79b72929295c18a2bcb3f81 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 25 Feb 2014 16:47:03 -0500 Subject: [PATCH] LP#1284864 TPAC metarecord display record count in results Next to each metarecord containing more than one record, display the count of constituent records next to the record title in parentheses. This allows the user to see at a glance if a record is really grouped or simply a single-record "group". Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 23 ++++++++++++++++++---- Open-ILS/src/templates/opac/parts/result/table.tt2 | 13 +++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 57e0bfb5e6..092bf1636e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -502,6 +502,20 @@ sub load_rresults { # load temporary_list settings for user and ou: $self->_load_lists_and_settings if ($ctx->{user}); + # fetch metarecord constituent counts for display + my $mr_counts = []; + if ($is_meta) { + $mr_counts = $e->json_query({ + select => {mmrsm => [{ + column => 'id', transform => 'count', + alias => 'count', aggregate => 1 + }, 'metarecord' + ]}, + from => 'mmrsm', + where => {'+mmrsm' => {metarecord => $rec_ids}} + }); + } + # shove recs into context in search results order for my $rec_id (@$rec_ids) { my ($rec) = grep { $_->{$id_key} == $rec_id } @data; @@ -510,10 +524,11 @@ sub load_rresults { $ctx->{metarecord_master} = $rec if $metarecord_master and $metarecord_master eq $rec_id; - # MR's with multiple constituent records will have a - # null value in position 2 of the result set. - my ($res_rec) = grep { $_->[0] == $rec_id} @{$results->{ids}}; - $rec->{mr_has_multi} = !$res_rec->[2]; + if ($is_meta) { + # add the count of constituent records to the metarecord + my ($count) = grep {$_->{metarecord} == $rec_id} @$mr_counts; + $rec->{mr_constituent_count} = $count->{count}; + } } if ($tag_circs) { diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2 index b927de2dad..483d529c07 100644 --- a/Open-ILS/src/templates/opac/parts/result/table.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/table.tt2 @@ -40,7 +40,7 @@ # note: rec.id refers to the record identifier, regardless # of the type of record. i.e. rec.id = mmr_id ? mmr_id : bre_id IF rec.mmr_id; - IF rec.mr_has_multi; + IF rec.mr_constituent_count > 1; # metarecords link to record list page record_url = mkurl(ctx.opac_root _ '/results', {metarecord => rec.mmr_id}, ['page']); @@ -77,8 +77,15 @@ [% END %] [% attrs.title | html %] + [% html_text_attr('title', l('Display record details for "[_1]"', attrs.title)) %]> + [% attrs.title | html %] + + [% IF rec.mr_constituent_count > 1 %] + + ([% rec.mr_constituent_count %]) + + [% END %] + [%- FOR entry IN attrs.graphic_titles; FOR alt IN entry.graphic; -- 2.11.0