From b3094c0a915a690ae1e590bad318e699d767206e Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 22 Jul 2011 09:59:57 -0400 Subject: [PATCH] Shelf browser! Needs improvements: can't find jacket images by UPC yet Signed-off-by: Lebbeous Fogle-Weekley --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 26 +++++++++++ .../web/templates/default/opac/parts/cn_browse.tt2 | 44 ------------------ .../default/opac/parts/record/cnbrowse.tt2 | 52 ++++++++++++++++++++++ .../templates/default/opac/parts/record/extras.tt2 | 14 +++++- 4 files changed, 90 insertions(+), 46 deletions(-) delete mode 100644 Open-ILS/web/templates/default/opac/parts/cn_browse.tt2 create mode 100644 Open-ILS/web/templates/default/opac/parts/record/cnbrowse.tt2 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 02fd651c03..021ae62e17 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -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 index 282bfd9a6a..0000000000 --- a/Open-ILS/web/templates/default/opac/parts/cn_browse.tt2 +++ /dev/null @@ -1,44 +0,0 @@ - -
-
- [% l("Loading Callnumber Page...") %] -
-
-
- [% l("You are now browsing") %] - -
- - - - - - - - - - - - - -
- [% l("<< Previous Page") %] - [% l("Shelf Browser") %] - [% l("Next Page >>") %] -
- -
-
- -
-
- -
-
-
-
-
- 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 index 0000000000..64a0e1f728 --- /dev/null +++ b/Open-ILS/web/templates/default/opac/parts/record/cnbrowse.tt2 @@ -0,0 +1,52 @@ +
+
+
+ [% l("You are now browsing") %] + [% ctx.get_aou(CGI.param('loc')).name %] +
+ + + + + + + + + + [% tr_open = 0; FOR ent IN ctx.browsed_call_numbers %] + [%- IF loop.index % 3 == 0; tr_open = 1 %] + + [% END -%] + + [% IF loop.index % 3 == 2; tr_open = 0 %] + + [% END %] + [% END; IF tr_open %][% END %] + +
[% IF CGI.param("cnoffset") > 0 %] + [% + l("<< Previous Page") + %] + [% END %][% l("Shelf Browser") %][% IF ctx.browsed_call_numbers.size == 9 %] + [% + l("Next Page >>") + %] + [% END %]
+ [% # 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 %] + + [% END %] +
[% ent.cn.label %]
+ + +
[% ctx.get_aou(ent.cn.owning_lib).name %]
+
+
+
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 918cdcd1b5..2bfa8be320 100644 --- a/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 @@ -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')} ]; @@ -37,7 +37,17 @@