TPac: detail page distinct copy/holdings display depth
authorBill Erickson <berick@esilibrary.com>
Thu, 1 Mar 2012 15:18:49 +0000 (10:18 -0500)
committerDan Scott <dan@coffeecode.net>
Sun, 11 Mar 2012 00:57:19 +0000 (19:57 -0500)
This adds a new CGI param "copy_depth" which the record detail page uses
to determine which copies to display in the copy grid and what serials
holdings data to show.

The goal is to separate search depth from copy display depth for 2
main reasons:

1. When present, the search ou is set by the "locg" parameter (org +
copy location group).  The "Show" links in the record detail page use
"loc" to determine the copy location org (and subsequently the depth),
which is ignored in the presence of "locg".  In other words, we need
a different way to communicate which range of copies to display.

2. Separating copy depth and search depth allows us to display
search location-related summary information while at the same time
displaying a broader set of copy information.  For example, searching
BR1, we can see copy summary info for BR1, SYS1, and CONS even when
explicitly viewing copy information for CONS.  In other words, viewing a
broader set of copies for a record does not change the search/context
org unit, it only extends the set of copies to display.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Scott <dan@coffeecode.net>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/templates/opac/parts/record/copy_counts.tt2

index 3d1d6c8..2daaf2f 100644 (file)
@@ -15,7 +15,14 @@ sub load_record {
     $ctx->{page} = 'record';  
 
     my $org = $self->_get_search_lib();
-    my $depth = $self->cgi->param('depth') || $ctx->{get_aou}->($org)->ou_type->depth;
+    my $depth = $self->cgi->param('depth');
+    $depth = $ctx->{get_aou}->($org)->ou_type->depth 
+        unless defined $depth; # can be 0
+
+    my $copy_depth = $self->cgi->param('copy_depth');
+    $copy_depth = $depth unless defined $copy_depth; # can be 0
+    $self->ctx->{copy_depth} = $copy_depth;
+
     my $copy_limit = int($self->cgi->param('copy_limit') || 10);
     my $copy_offset = int($self->cgi->param('copy_offset') || 0);
 
@@ -34,7 +41,7 @@ sub load_record {
     my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
     my $copy_rec = $cstore->request(
         'open-ils.cstore.json_query.atomic', 
-        $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset)
+        $self->mk_copy_query($rec_id, $org, $copy_depth, $copy_limit, $copy_offset)
     );
 
     my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,bmp,mra,acp,acnp,acns}'});
@@ -47,6 +54,7 @@ sub load_record {
 
     $ctx->{have_holdings_to_show} = 0;
     $ctx->{have_mfhd_to_show} = 0;
+
     $self->get_hold_copy_summary($rec_id, $org);
 
     $cstore->kill_me;
@@ -56,7 +64,7 @@ sub load_record {
             ($org, "opac.fully_compressed_serial_holdings")
     ) {
         $ctx->{holding_summaries} =
-            $self->get_holding_summaries($rec_id, $org, $depth);
+            $self->get_holding_summaries($rec_id, $org, $copy_depth);
 
         $ctx->{have_holdings_to_show} =
             scalar(@{$ctx->{holding_summaries}->{basic}}) ||
@@ -64,7 +72,7 @@ sub load_record {
             scalar(@{$ctx->{holding_summaries}->{supplement}});
     } else {
         $ctx->{mfhd_summaries} =
-            $self->get_mfhd_summaries($rec_id, $org, $depth);
+            $self->get_mfhd_summaries($rec_id, $org, $copy_depth);
 
         if ($ctx->{mfhd_summaries} && scalar(@{$ctx->{mfhd_summaries}})
         ) {
@@ -78,7 +86,7 @@ sub load_record {
         },
         issues => sub {
             $ctx->{expanded_holdings} =
-                $self->get_expanded_holdings($rec_id, $org, $depth)
+                $self->get_expanded_holdings($rec_id, $org, $copy_depth)
                 if $ctx->{have_holdings_to_show};
         },
         cnbrowse => sub {
index defa0ae..f9f5594 100644 (file)
@@ -8,10 +8,10 @@
             ou_id = ctx.copy_summary.$depth.org_unit;
     %]
     <li>
-    [% l('[quant,_1,copy,copies] at [_2].', ou_avail, ctx.get_aou(ou_id).name)
-        | html %]
-    [%- IF ou_avail > 0 && ou_id != ctx.search_ou; %]
-    <a href="[% mkurl('', {loc => ou_id}); %]"
+    [% l('[quant,_1,copy,copies] at [_2].', ou_avail, ctx.get_aou(ou_id).name) | html %]
+    [%- this_depth = ctx.get_aou(ou_id).ou_type.depth;
+        IF ou_avail > 0 && this_depth != ctx.copy_depth %]
+    <a href="[% mkurl('', {copy_depth => this_depth}, ['copy_offset']); %]"
        title="[% l('Show copies at [_1]', ctx.get_aou(ou_id).name); %]">
        [%- l('(Show)'); %]</a>
     [%- END; %]