From 2bfb4891c6908e0e3ec34f69e0393c7fc50762b2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 11 Aug 2011 16:59:22 -0400 Subject: [PATCH] TTpac: Added Expand/Collaps all 'extras' tabs in detail page Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 27 ++++++++++++++++------ .../templates/default/opac/parts/record/extras.tt2 | 2 +- .../default/opac/parts/record/summary.tt2 | 12 ++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 07cfdf6a68..b1c91d0157 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -57,17 +57,30 @@ sub load_record { scalar(@{$ctx->{holding_summaries}->{supplement}}); } - # XXX probably should replace the following with a dispatch table - for my $expand ($self->cgi->param('expand')) { - $ctx->{"expand_$expand"} = 1; - if ($expand eq 'marchtml') { + my %expandies = ( + marchtml => sub { $ctx->{marchtml} = $self->mk_marc_html($rec_id); - } elsif ($expand eq 'issues' and $ctx->{have_holdings_to_show}) { + }, + issues => sub { $ctx->{expanded_holdings} = - $self->get_expanded_holdings($rec_id, $org, $depth); - } elsif ($expand eq 'cnbrowse') { + $self->get_expanded_holdings($rec_id, $org, $depth) + if $ctx->{have_holdings_to_show}; + }, + cnbrowse => sub { $self->prepare_browse_call_numbers(); } + ); + + my @expand = $self->cgi->param('expand'); + if (grep {$_ eq 'all'} @expand) { + $ctx->{expand_all} = 1; + $expandies{$_}->() for keys %expandies; + + } else { + for my $exp (@expand) { + $ctx->{"expand_$exp"} = 1; + $expandies{$exp}->() if exists $expandies{$exp}; + } } return Apache2::Const::OK; diff --git a/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 b/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 index d22377aed9..a800317f70 100644 --- a/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 @@ -45,7 +45,7 @@
[% exp_name = 'expand_' _ name; - IF ctx.$exp_name; + IF ctx.$exp_name OR ctx.expand_all; IF name == 'marchtml'; ctx.marchtml; ELSE; diff --git a/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 b/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 index 6a833dd2b8..60a9df2de6 100644 --- a/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 @@ -217,6 +217,18 @@ [% END %] + + + [% IF CGI.param('expand') == 'all' %] + + [% l('Collapse all tabs') %] + [% ELSE %] + + [% l('Expand all tabs') %] + [% END %] + + + -- 2.11.0