From 5eaca7025ae869baf1ce6df026fb212eb13872c6 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 4 May 2012 12:07:35 -0400 Subject: [PATCH] TPAC: repair staff client End link for showing last record In the embedded TPAC, when staff clicks the End link in the record detail page to jump to the last record in the search results, it now makes an intermediate jump through search code, which locates the last record in the set (via CGI param find_last) then redirects to the record detail page for the last record. With this approach, we don't have to pre-fetch the entire set of record IDs just to render the paging links. Tip o' the hat to Mike R. for the design suggestion. https://bugs.launchpad.net/evergreen/+bug/984070 Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 14 +++++++++++++- Open-ILS/src/templates/opac/parts/js.tt2 | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) 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 b10f312baa..53365e0bfc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -265,6 +265,9 @@ sub load_rresults { my $ctx = $self->ctx; my $e = $self->editor; + # find the last record in the set, then redirect + my $find_last = $cgi->param('find_last'); + $self->timelog("Loading results"); # load bookbag metadata, if requested. if (my $bbag_err = $self->load_rresults_bookbag) { @@ -316,7 +319,7 @@ sub load_rresults { $self->get_staff_search_settings; - if ($ctx->{staff_saved_search_size}) { + if (!$find_last and $ctx->{staff_saved_search_size}) { my ($key, $list) = $self->staff_save_search($query); if ($key) { $self->apache->headers_out->add( @@ -390,6 +393,15 @@ sub load_rresults { $ctx->{hit_count} = $results->{count}; $ctx->{parsed_query} = $results->{parsed_query}; + if ($find_last) { + # redirect to the record detail page for the last record in the results + my $rec_id = pop @$rec_ids; + $cgi->delete('find_last'); + my $url = $cgi->url(-full => 1, -path => 1, -query => 1); + $url =~ s|/results|/record/$rec_id|; + return $self->generic_redirect($url); + } + return Apache2::Const::OK if @$rec_ids == 0 or $internal; $self->load_rresults_bookbag_item_notes($rec_ids) if $ctx->{bookbag}; diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2 index 517b2300f2..df50a03559 100644 --- a/Open-ILS/src/templates/opac/parts/js.tt2 +++ b/Open-ILS/src/templates/opac/parts/js.tt2 @@ -12,7 +12,7 @@ "[% ctx.prev_rec_url || '' %]", "[% ctx.next_rec_url || '' %]", "[% mkurl(ctx.first_search_record, {page => 0}) %]", - "[% mkurl(ctx.last_search_record, {page => POSIX.floor(ctx.hit_count / ctx.page_size)}) %]", + "[% mkurl(ctx.opac_root _ '/results', {find_last => 1, page => POSIX.floor(ctx.hit_count / ctx.page_size)}) %]", "[% mkurl(ctx.opac_root _ '/results', {}, ['expand','cnoffset']) %]" ); -- 2.43.2