TTpac: Added Expand/Collaps all 'extras' tabs in detail page
authorBill Erickson <berick@esilibrary.com>
Thu, 11 Aug 2011 20:59:22 +0000 (16:59 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 11 Aug 2011 20:59:22 +0000 (16:59 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/record/extras.tt2
Open-ILS/web/templates/default/opac/parts/record/summary.tt2

index 07cfdf6..b1c91d0 100644 (file)
@@ -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;
index d22377a..a800317 100644 (file)
@@ -45,7 +45,7 @@
         </div>
         <div class='rdetail_extras_div'>
             [%  exp_name = 'expand_' _ name;
-                IF ctx.$exp_name;
+                IF ctx.$exp_name OR ctx.expand_all;
                     IF name == 'marchtml';
                         ctx.marchtml;
                     ELSE;
index 6a833dd..60a9df2 100644 (file)
                 [% END %]
             </td>
         </tr>
+        <tr>
+            <td>
+                [% IF CGI.param('expand') == 'all' %]
+                    <img src="[% ctx.media_prefix %]/images/minus_sign.png" />
+                    <a href="[% mkurl('', {}, ['expand']) %]">[% l('Collapse all tabs') %]</a>
+                [% ELSE %]
+                    <img src="[% ctx.media_prefix %]/images/plus_sign.png" />
+                    <a href="[% mkurl('', {expand => 'all'}) %]">[% l('Expand all tabs') %]</a>
+                [% END %]
+            </td>
+        </tr>
+
     </tbody>
 </table>