From a8338b6194cd5bded07210316ff9376a7865f5e0 Mon Sep 17 00:00:00 2001 From: Bob Wicksall Date: Fri, 29 Jun 2012 14:33:22 -0400 Subject: [PATCH] TPac: Add paging to My Lists - Added paging to My Lists based on the code from the Checkout History tab. - Fixed a bug where adding more than 10 items to the Temporary list failed - After adding paging renaming a list on page 2+ would fail. Fixed. - Redirect after saving a list now leaves you on the same page - Paging was bleeding between My Lists, Holds History and Circ History. Fixed. List contents were also limited to the first 10. I have upped the limit to 1000 rather than having nested paging. This should be revisited. CSV download of lists is still limited to the first 10. Not sure where to fix this. Signed-off-by: Bob Wicksall Signed-off-by: Ben Shum Signed-off-by: Jason Stephenson Signed-off-by: Lebbeous Fogle-Weekley --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 77 ++++++++++++---------- .../lib/OpenILS/WWW/EGCatLoader/Container.pm | 6 +- Open-ILS/src/templates/opac/myopac/lists.tt2 | 19 +++++- Open-ILS/src/templates/opac/parts/myopac/base.tt2 | 2 +- 4 files changed, 66 insertions(+), 38 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 2346542f85..5038851c08 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -1620,6 +1620,11 @@ sub load_myopac_bookbags { my $self = shift; my $e = $self->editor; my $ctx = $self->ctx; + my $limit = $self->cgi->param('limit') || 10; + my $offset = $self->cgi->param('offset') || 0; + + $ctx->{bookbags_limit} = $limit; + $ctx->{bookbags_offset} = $offset; my ($sorter, $modifier) = $self->_get_bookbag_sort_params("sort"); $e->xact_begin; # replication... @@ -1634,8 +1639,8 @@ sub load_myopac_bookbags { [ {owner => $e->requestor->id, btype => 'bookbag'}, { order_by => {cbreb => 'name'}, - limit => $self->cgi->param('limit') || 10, - offset => $self->cgi->param('offset') || 0 + limit => $limit, + offset => $offset } ], {substream => 1} @@ -1653,48 +1658,50 @@ sub load_myopac_bookbags { my ($bookbag) = grep { $_->id eq $self->cgi->param("bbid") } @{$ctx->{bookbags}}; - if (!$bookbag) { - $e->rollback; - return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; - } - - if ( ($self->cgi->param("action") || '') eq "editmeta") { - if (!$self->_update_bookbag_metadata($bookbag)) { - $e->rollback; - return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; - } else { - $e->commit; - my $url = $self->ctx->{opac_root} . '/myopac/lists?bbid=' . - $bookbag->id; + if ($bookbag) { + if ( ($self->cgi->param("action") || '') eq "editmeta") { + if (!$self->_update_bookbag_metadata($bookbag)) { + $e->rollback; + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + } else { + $e->commit; + my $url = $self->ctx->{opac_root} . '/myopac/lists?bbid=' . + $bookbag->id; - foreach my $param (('loc', 'qtype', 'query', 'sort')) { - if ($self->cgi->param($param)) { - $url .= ";$param=" . uri_escape($self->cgi->param($param)); + foreach my $param (('loc', 'qtype', 'query', 'sort', 'offset', 'limit')) { + if ($self->cgi->param($param)) { + $url .= ";$param=" . uri_escape($self->cgi->param($param)); + } } - } - return $self->generic_redirect($url); + return $self->generic_redirect($url); + } } - } - my $query = $self->_prepare_bookbag_container_query( - $bookbag->id, $sorter, $modifier - ); + my $query = $self->_prepare_bookbag_container_query( + $bookbag->id, $sorter, $modifier + ); - # XXX we need to limit the number of records per bbag; use third arg - # of bib_container_items_via_search() i think. - my $items = $U->bib_container_items_via_search($bookbag->id, $query) - or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + # XXX Limiting to 1000 for now. This way you should be able to see entire + # list contents. Need to add paging here instead. + my $args = { + "limit" => 1000, + "offset" => 0 + }; - my (undef, @recs) = $self->get_records_and_facets( - [ map {$_->target_biblio_record_entry->id} @$items ], - undef, - {flesh => '{mra}'} - ); + my $items = $U->bib_container_items_via_search($bookbag->id, $query, $args) + or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + + my (undef, @recs) = $self->get_records_and_facets( + [ map {$_->target_biblio_record_entry->id} @$items ], + undef, + {flesh => '{mra}'} + ); - $ctx->{bookbags_marc_xml}{$_->{id}} = $_->{marc_xml} for @recs; + $ctx->{bookbags_marc_xml}{$_->{id}} = $_->{marc_xml} for @recs; - $bookbag->items($items); + $bookbag->items($items); + } } $e->rollback; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm index 6cc67966cf..ba7a6cec8d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm @@ -38,7 +38,11 @@ sub fetch_mylist { if (@$list) { my ($sorter, $modifier) = $self->_get_bookbag_sort_params("anonsort"); my $query = $self->_prepare_anonlist_sorting_query($list, $sorter, $modifier); - $list = $U->bib_record_list_via_search($query) or + my $args = { + "limit" => 1000, + "offset" => 0 + }; + $list = $U->bib_record_list_via_search($query, $args) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; } diff --git a/Open-ILS/src/templates/opac/myopac/lists.tt2 b/Open-ILS/src/templates/opac/myopac/lists.tt2 index efefd4d6f4..88972c6c22 100644 --- a/Open-ILS/src/templates/opac/myopac/lists.tt2 +++ b/Open-ILS/src/templates/opac/myopac/lists.tt2 @@ -1,7 +1,10 @@ [% PROCESS "opac/parts/header.tt2"; PROCESS "opac/parts/misc_util.tt2"; WRAPPER "opac/parts/myopac/base.tt2"; - myopac_page = "lists" %] + myopac_page = "lists" + limit = ctx.bookbags_limit; + offset = ctx.bookbags_offset; +%]
@@ -52,6 +55,18 @@

[% l("Your existing lists") %]

[% INCLUDE "opac/parts/anon_list.tt2" %] [% IF ctx.bookbags.size %] + +
+
[% FOR bbag IN ctx.bookbags %]
@@ -133,6 +148,8 @@
+ + [%- INCLUDE "opac/parts/preserve_params.tt2"; %] diff --git a/Open-ILS/src/templates/opac/parts/myopac/base.tt2 b/Open-ILS/src/templates/opac/parts/myopac/base.tt2 index 763e65b44a..c433c6a9ca 100644 --- a/Open-ILS/src/templates/opac/parts/myopac/base.tt2 +++ b/Open-ILS/src/templates/opac/parts/myopac/base.tt2 @@ -23,7 +23,7 @@ ELSE; cls_which = "acct-tab-off"; END -%] - [% page.name; %] [% END %] -- 2.11.0