From: Lebbeous Fogle-Weekley
Date: Tue, 15 Nov 2011 06:50:00 +0000 (-0500)
Subject: Tpac: better "HTML view" for shared lists under "my lists"
X-Git-Tag: sprint4-merge-nov22~4661^2
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fsenator%2Ftpac-bookbag-viewer;p=working%2FEvergreen.git
Tpac: better "HTML view" for shared lists under "my lists"
From the "my lists" interface, you get a link labeled "HTML View" for
any shared lists, and this link, while meant to be shared, just
gives you a search results page where the only search term is simply "in
the given list."
This commit makes the search results page a little smarter in that case,
in order to
a) show you the bookbag metadata, including name, description and
item notes.
b) allow you to keep searching *within* your list, until you don't
want to anymore, at which point there's a checkbox you can uncheck.
Signed-off-by: Lebbeous Fogle-Weekley
---
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index 6e74628a9a..bce9cdbc70 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -82,6 +82,10 @@ sub _prepare_biblio_search {
}
}
+ if ($cgi->param("bookbag")) {
+ $query .= " container(bre,bookbag," . int($cgi->param("bookbag")) . ")";
+ }
+
if ($cgi->param('pubdate') && $cgi->param('date1')) {
if ($cgi->param('pubdate') eq 'between') {
$query .= ' between(' . $cgi->param('date1');
@@ -170,6 +174,62 @@ sub tag_circed_items {
return 0 unless @$sets;
return 1;
+
+}
+
+# This only loads the bookbag itself (in support of a record results page)
+# if a "bookbag" CGI parameter is specified and if the bookbag is public
+# or owned by the logged-in user (if any). Bookbag notes are fetched
+# later if applicable.
+sub load_rresults_bookbag {
+ my ($self) = @_;
+
+ my $bookbag_id = int($self->cgi->param("bookbag"));
+ return if $bookbag_id < 1;
+
+ my %authz = $self->ctx->{"user"} ?
+ ("-or" => {"pub" => "t", "owner" => $self->ctx->{"user"}->id}) :
+ ("pub" => "t");
+
+ my $bbag = $self->editor->search_container_biblio_record_entry_bucket(
+ {"id" => $bookbag_id, "btype" => "bookbag", %authz}
+ );
+
+ if (!$bbag) {
+ $self->apache->log->warn(
+ "error from cstore retrieving bookbag $bookbag_id!"
+ );
+ return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
+ } elsif (@$bbag) {
+ $self->ctx->{"bookbag"} = shift @$bbag;
+ }
+
+ return;
+}
+
+# assumes context has a bookbag we're already authorized to look at, and
+# a list of rec_ids, reasonably sized (from paged search).
+sub load_rresults_bookbag_item_notes {
+ my ($self, $rec_ids) = @_;
+
+ my $items_with_notes =
+ $self->editor->search_container_biblio_record_entry_bucket_item([
+ {"target_biblio_record_entry" => $rec_ids,
+ "bucket" => $self->ctx->{"bookbag"}->id},
+ {"flesh" => 1, "flesh_fields" => {"cbrebi" => ["notes"]},
+ "order_by" => {"cbrebi" => ["id"]}}
+ ]);
+
+ if (!$items_with_notes) {
+ $self->apache->log->warn("error from cstore retrieving cbrebi objects");
+ return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ $self->ctx->{"bookbag_items_by_bre_id"} = +{
+ map { $_->target_biblio_record_entry => $_ } @$items_with_notes
+ };
+
+ return;
}
# context additions:
@@ -184,6 +244,11 @@ sub load_rresults {
my $ctx = $self->ctx;
my $e = $self->editor;
+ # load bookbag metadata, if requested.
+ if (my $bbag_err = $self->load_rresults_bookbag) {
+ return $bbag_err;
+ }
+
$ctx->{page} = 'rresult' unless $internal;
$ctx->{ids} = [];
$ctx->{records} = [];
@@ -294,6 +359,8 @@ sub load_rresults {
return Apache2::Const::OK if @$rec_ids == 0 or $internal;
+ $self->load_rresults_bookbag_item_notes($rec_ids) if $ctx->{bookbag};
+
my ($facets, @data) = $self->get_records_and_facets(
$rec_ids, $results->{facet_key},
{
diff --git a/Open-ILS/src/templates/opac/myopac/lists.tt2 b/Open-ILS/src/templates/opac/myopac/lists.tt2
index 41c77f9c4c..45404e84a3 100644
--- a/Open-ILS/src/templates/opac/myopac/lists.tt2
+++ b/Open-ILS/src/templates/opac/myopac/lists.tt2
@@ -102,7 +102,7 @@
diff --git a/Open-ILS/src/templates/opac/parts/result/lowhits.tt2 b/Open-ILS/src/templates/opac/parts/result/lowhits.tt2
index db8266a196..f6f39b2d73 100644
--- a/Open-ILS/src/templates/opac/parts/result/lowhits.tt2
+++ b/Open-ILS/src/templates/opac/parts/result/lowhits.tt2
@@ -8,6 +8,11 @@
[% IF is_advanced OR is_special; l('your search'); ELSE %]
[% CGI.param('query') | html %]
[% END %]
+ [% IF ctx.bookbag;
+ l('within') %]
+ [% ctx.bookbag.name | html %].
+ [% END %]
+
diff --git a/Open-ILS/src/templates/opac/parts/result/paginate.tt2 b/Open-ILS/src/templates/opac/parts/result/paginate.tt2
index 6582c01bb8..bcce1c8a87 100644
--- a/Open-ILS/src/templates/opac/parts/result/paginate.tt2
+++ b/Open-ILS/src/templates/opac/parts/result/paginate.tt2
@@ -2,7 +2,7 @@