TPAC: tentative MFHD display steps
authorDan Scott <dscott@laurentian.ca>
Sun, 18 Sep 2011 05:37:37 +0000 (01:37 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 26 Sep 2011 14:33:08 +0000 (10:33 -0400)
Retrieve and display MFHD records in the TPAC, piggybacking on the
"Issues" twisty section.

TODO: Take org_unit & depth into account when deciding which MFHD
records to display. Right now we're just showing all of them.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/templates/opac/parts/record/extras.tt2
Open-ILS/src/templates/opac/parts/record/issues.tt2

index bc60edc..2a42644 100644 (file)
@@ -44,11 +44,11 @@ sub load_record {
     $ctx->{copy_offset} = $copy_offset;
 
     $ctx->{have_holdings_to_show} = 0;
+    $ctx->{have_mfhd_to_show} = 0;
     $self->get_hold_copy_summary($rec_id, $org);
 
     $cstore->kill_me;
 
-    # XXX TODO we'll also need conditional logic to show MFHD-based holdings
     if (
         $ctx->{get_org_setting}->
             ($org, "opac.fully_compressed_serial_holdings")
@@ -60,6 +60,14 @@ sub load_record {
             scalar(@{$ctx->{holding_summaries}->{basic}}) ||
             scalar(@{$ctx->{holding_summaries}->{index}}) ||
             scalar(@{$ctx->{holding_summaries}->{supplement}});
+    } else {
+        $ctx->{mfhd_summaries} =
+            $self->get_mfhd_summaries($rec_id, $org, $depth);
+
+        if ($ctx->{mfhd_summaries} && scalar(@{$ctx->{mfhd_summaries}})
+        ) {
+            $ctx->{have_mfhd_to_show} = 1;
+        };
     }
 
     my %expandies = (
@@ -208,6 +216,21 @@ sub get_holding_summaries {
     return $result;
 }
 
+sub get_mfhd_summaries {
+    my ($self, $rec_id, $org, $depth) = @_;
+
+    # XXX TODO Filter results on OU / depth before returning
+    # Perhaps in a modified form of the osrf method, rather than here
+    my $serial = create OpenSRF::AppSession("open-ils.search");
+    my $result = $serial->request(
+        "open-ils.search.serial.record.bib.retrieve",
+        $rec_id
+    )->gather(1);
+
+    $serial->kill_me;
+    return $result;
+}
+
 sub get_expanded_holdings {
     my ($self, $rec_id, $org, $depth) = @_;
 
index 7c7339d..5bf5716 100644 (file)
@@ -23,7 +23,7 @@
             {name => 'annotation', label => l('Annotation'), hide => 1}, 
             {name => 'awards',  label => l('Awards, Reviews, & Suggested Reads')}, 
             {name => 'excerpt',  label => l('Excerpt'), hide => 1},
-            {name => 'issues',   label => l('Issues Held'), hide => !ctx.have_holdings_to_show},
+            {name => 'issues',   label => l('Issues Held'), hide => !(ctx.have_holdings_to_show || ctx.have_mfhd_to_show)},
             {name => 'preview',  label => l('Preview'), hide => 1}, 
             {name => 'cnbrowse', label => l('Shelf Browser')},
             {name => 'marchtml', label => l('MARC Record')}
index e13efb2..47f63f0 100644 (file)
@@ -23,4 +23,33 @@ FOREACH type IN ctx.holding_summaries.keys;
         [% END %]
     </div>
 [% END %]
+[% IF ctx.mfhd_summaries.size; %]
+    <div class="rdetail-mfhd-holdings">
+        <table>
+[%
+        mfhd = {
+            basic_holdings = l('Volumes'),
+            basic_holdings_add = l('Additional Volume Information'),
+            supplement_holdings = l('Supplements'),
+            supplement_holdings_add = l('Additional Supplement Information'),
+            index_holdings = l('Indexes'),
+            index_holdings_add = l('Additional Index Information'),
+            online = l('Online'),
+            missing = l('Missing'),
+            incomplete = l('Incomplete'),
+        };
+
+        FOREACH serial IN ctx.mfhd_summaries;
+            FOREACH type IN mfhd.keys;
+                NEXT UNLESS serial.$type.size;
+%]
+            <tr>
+                <td class="rdetail-mfhd-type">[% mfhd.$type %]</td>
+                <td class="rdetail-mfhd-contents">[% serial.$type.join(', ') %]</td>
+            </tr>
+        [% END %]
+    [% END %]
+        </table>
+    </div>
+[% END %]
 </div>