Shelf browser!
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 22 Jul 2011 13:59:57 +0000 (09:59 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 22 Jul 2011 13:59:57 +0000 (09:59 -0400)
Needs improvements: can't find jacket images by UPC yet

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/cn_browse.tt2 [deleted file]
Open-ILS/web/templates/default/opac/parts/record/cnbrowse.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/record/extras.tt2

index 02fd651..021ae62 100644 (file)
@@ -53,6 +53,7 @@ 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') {
@@ -60,7 +61,10 @@ sub load_record {
         } elsif ($expand eq 'issues' and $ctx->{have_holdings_to_show}) {
             $ctx->{expanded_holdings} =
                 $self->get_expanded_holdings($rec_id, $org, $depth);
+        } elsif ($expand eq 'cnbrowse') {
+            $ctx->{browsed_call_numbers} = $self->browse_call_numbers();
         }
+
     }
 
     return Apache2::Const::OK;
@@ -185,6 +189,28 @@ sub get_expanded_holdings {
     )->gather(1);
 }
 
+sub any_call_number_label {
+    my ($self) = @_;
+
+    if ($self->ctx->{copies} and @{$self->ctx->{copies}}) {
+        return $self->ctx->{copies}->[0]->{call_number_label};
+    } else {
+        return;
+    }
+}
+
+sub browse_call_numbers {
+    my ($self) = @_;
+
+    my $cn = $self->any_call_number_label or return [];
+
+    my $search = create OpenSRF::AppSession("open-ils.search");
+
+    return $search->request(
+        "open-ils.search.callnumber.browse", 
+        $cn, map { $self->cgi->param($_) } qw/loc cnoffset/, 9
+    )->gather(1);
+}
 
 sub get_hold_copy_summary {
     my ($self, $rec_id, $org) = @_;
diff --git a/Open-ILS/web/templates/default/opac/parts/cn_browse.tt2 b/Open-ILS/web/templates/default/opac/parts/cn_browse.tt2
deleted file mode 100644 (file)
index 282bfd9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<!-- ****************** cn_browse.xml ***************************** -->
-<div id='cn_browse' class='cn_browser'>
-    <div id='cn_browse_loading' class='cn_browse_loading hide_me'>
-        [% l("Loading Callnumber Page...") %]
-    </div>
-    <div id='cn_browse_div'> 
-        <div class='color_4'>
-            <span>[% l("You are now browsing") %]</span>
-            <b id='cn_browse_where'> </b>
-        </div>
-        <table class='data_grid bookshelf' width='100%'>
-            <thead>
-                <tr>
-                    <td>
-                        <a id='cn_browse_next' class='classic_link' 
-                        href='javascript:cnBrowsePrev();'><b>[% l("&lt;&lt; Previous Page") %]</b></a>
-                    </td>
-                    <td colspan='1' align='center'>[% l("Shelf Browser") %]</td>
-                    <td>
-                        <a id='cn_browse_prev' class='classic_link' 
-                            href='javascript:cnBrowseNext();'><b>[% l("Next Page &gt;&gt;") %]</b></a>
-                    </td>
-                </tr>
-            </thead>
-            <tbody id='cn_tbody'>
-                <tr id='cn_browse_row'>
-                    <td id='cn_browse_td' class='cn_browse_item' width='25%' valign='top'>
-                        <a><img height='60' width='50' 
-                            class='cn_browse_info' name='cn_browse_pic' border='0' /></a>
-                        <div class='cn_browse_info bold' name='cn_browse_cn'></div>
-                        <div class='cn_browse_info'>
-                            <a name='cn_browse_title' class='classic_link'></a>
-                        </div>
-                        <div class='cn_browse_info'>
-                            <a name='cn_browse_author' class='classic_link'>  </a>
-                        </div>
-                        <div class='cn_browse_info' name='cn_browse_lib'>  </div>
-                    </td>
-                </tr>
-            </tbody>
-        </table>
-    </div>
-</div>
-<!-- ****************** end: cn_browse.xml ***************************** -->
diff --git a/Open-ILS/web/templates/default/opac/parts/record/cnbrowse.tt2 b/Open-ILS/web/templates/default/opac/parts/record/cnbrowse.tt2
new file mode 100644 (file)
index 0000000..64a0e1f
--- /dev/null
@@ -0,0 +1,52 @@
+<div id='cn_browse' class='cn_browser'>
+    <div id='cn_browse_div'> 
+        <div class='color_4'>
+            <span>[% l("You are now browsing") %]</span>
+            <strong>[% ctx.get_aou(CGI.param('loc')).name %]</strong>
+        </div>
+        <table class='data_grid bookshelf' width='100%'>
+            <thead>
+                <tr>
+                    <td>[% IF CGI.param("cnoffset") > 0 %]
+                        <a id='cn_browse_prev' class='classic_link' href=">[% ctx.opac_root %]/record/[% ctx.bre_id _ extras_propagator _ '&amp;cnoffset=' _ ((CGI.param('cnoffset') || 0) - 1) _ '&amp;expand=cnbrowse#cnbrowse' %]"<b>[%
+                            l("&lt;&lt; Previous Page")
+                        %]</b></a>
+                        [% END %]</td>
+                    <td colspan='1' align='center'>[% l("Shelf Browser") %]</td>
+                    <td>[% IF ctx.browsed_call_numbers.size == 9 %]
+                        <a id='cn_browse_next' class='classic_link' href="[% ctx.opac_root %]/record/[% ctx.bre_id _ extras_propagator _ '&amp;cnoffset=' _ ((CGI.param('cnoffset') || 0) + 1) _ '&amp;expand=cnbrowse#cnbrowse' %]"<b>[%
+                            l("Next Page &gt;&gt;")
+                        %]</b></a>
+                        [% END %]</td>
+                </tr>
+            </thead>
+            <tbody id='cn_tbody'>
+            [% tr_open = 0; FOR ent IN ctx.browsed_call_numbers %]
+                [%- IF loop.index % 3 == 0; tr_open = 1 %]
+                <tr id='cn_browse_row'>
+                [% END -%]
+                    <td id='cn_browse_td' class='cn_browse_item' width='25%' valign='top'>
+                        [%  # Not to extend to life of the mvr fieldmapper class,
+                            # but should we add a upc field to it to make this better?
+                            IF ent.mods.isbn %]
+                        <a href="[% ctx.opac_root %]/record/[% ent.cn.record _ extras_propagator %]"><img height='60' width='50' 
+                            class='cn_browse_info' name='cn_browse_pic' border='0'
+                            src="[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ent.mods.isbn %]" /></a>
+                        [% END %]
+                        <div class='cn_browse_info bold' name='cn_browse_cn'>[% ent.cn.label %]</div>
+                        <div class='cn_browse_info'>
+                            <a name='cn_browse_title' class='classic_link' href="[% ctx.opac_root %]/record/[% ent.cn.record _ extras_propagator %]">[% ent.mods.title %]</a>
+                        </div>
+                        <div class='cn_browse_info'>
+                            <a name='cn_browse_author' class='classic_link'>[% ent.mods.author %]</a>
+                        </div>
+                        <div class='cn_browse_info' name='cn_browse_lib'>[% ctx.get_aou(ent.cn.owning_lib).name %]</div>
+                    </td>
+                [% IF loop.index % 3 == 2; tr_open = 0 %]
+                </tr>
+                [% END %]
+            [% END; IF tr_open %]</tr>[% END %]
+            </tbody>
+        </table>
+    </div>
+</div>
index 918cdcd..2bfa8be 100644 (file)
@@ -25,7 +25,7 @@
             {name => 'excerpt',  label => l('Excerpt'), hide => 1},
             {name => 'issues',   label => l('Issues Held'), hide => !ctx.have_holdings_to_show},
             {name => 'preview',  label => l('Preview'), hide => 1}, 
-            {name => 'cnbrowse', label => l('Shelf Browser'), hide => 1},
+            {name => 'cnbrowse', label => l('Shelf Browser')},
             {name => 'copyinfo', label => l('Copy Summary'), hide => 1}, 
             {name => 'marchtml', label => l('MARC Record')}
         ];
         <div class="rdetail_extras">
             <div class="rdetail_extras_hr"></div>
             <div class="rdetail_extras_link">
-                [% href = ctx.full_path _ '?expand=' _ name _ '#' _ name; %]
+                [%  # extras_propagator should be used in place of propagator
+                    # in opac extras interfaces... it just avoids duplicating
+                    # the expands CGI param and parameters that are specific
+                    # to extras.
+                    # XXX move this off into a helper function
+
+                    extras_propagator = propagator.replace('&amp;expand=.+($|&|;)', '$1');
+                    extras_propagator = extras_propagator.replace('&amp;cnoffset=.+($|&|;)', '$1');
+
+
+                    href = ctx.full_path _ extras_propagator _ '&amp;expand=' _ name _ '#' _ name; %]
                 <a name='[% name %]' href='[% href %]'><img
                     alt='[% extra.label %]' src="[% ctx.media_prefix %]/images/rdetail_arrow.png" /></a>
                 <a href='[% href %]' class="rdetail_extras_lbl">[% extra.label %]</a>