Bug 13205: [FOLLOW-UP] Some extra logic

See Comment 8.

Test:
When on first page of results, confirm that the 'First' and 'Previous'
buttons do not show. Confirm they come back on the second page and every
page after.
When on last page of results, confirm that the 'Last' and 'Next' buttons
do not show. Confirm they come back on all previous pages.
Check on both staff side and OPAC.

Sponsored-by: Catalyst IT

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Aleisha Amohia 2017-06-27 04:36:56 +00:00 committed by Jonathan Druart
parent 1a157575d3
commit 5fc0a1f5b1
4 changed files with 13 additions and 9 deletions

View File

@ -617,7 +617,7 @@ for (my $i=0;$i<@servers;$i++) {
my @page_numbers;
# total number of pages there will be
my $pages = ceil($hits / $results_per_page);
my $last_page = ($pages * $results_per_page) - $results_per_page;
my $last_page = $pages * ( $results_per_page - 1 );
# default page number
my $current_page_number = 1;
$current_page_number = ($offset / $results_per_page + 1) if $offset;

View File

@ -1,7 +1,9 @@
[% IF ( PAGE_NUMBERS ) %]<nav><ul class="pagination">
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">First</a></li>
<!-- Row of numbers corresponding to search result pages -->
[% IF ( previous_page_offset.defined ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% previous_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">&lt;&lt; Previous</a></li>[% END %]
[% IF ( previous_page_offset.defined ) %]
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">First</a></li>
<!-- Row of numbers corresponding to search result pages -->
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% previous_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">&lt;&lt; Previous</a></li>
[% END %]
[% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
[% IF ( PAGE_NUMBER.highlight ) %]
<li class="active"><span>[% PAGE_NUMBER.pg %]</span></li>
@ -9,6 +11,8 @@
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>
[% END %]
[% END %]
[% IF ( next_page_offset ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% next_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Next &gt;&gt;</a></li>[% END %]
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% last_page %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Last</a></li>
[% IF ( next_page_offset ) %]
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% next_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Next &gt;&gt;</a></li>
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% last_page %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">Last</a></li>
[% END %]
</ul></nav>[% END %]

View File

@ -1,8 +1,8 @@
[% IF ( PAGE_NUMBERS ) %]
<div class="pagination pagination-small noprint">
<ul>
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">First</a></li>
[% IF ( previous_page_offset.defined ) %]
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">First</a></li>
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% previous_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">&laquo; Previous</a></li>
[% END %]
[% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
@ -14,8 +14,8 @@
[% END %]
[% IF ( next_page_offset ) %]
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% next_page_offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">Next &raquo;</a></li>
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% last_page %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">Last</a></li>
[% END %]
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% last_page %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">Last</a></li>
</ul>
</div>
[% END %]

View File

@ -839,7 +839,7 @@ for (my $i=0;$i<@servers;$i++) {
my @page_numbers;
# total number of pages there will be
my $pages = ceil($hits / $results_per_page);
my $last_page = ($pages * $results_per_page) - $results_per_page;
my $last_page = $pages * ( $results_per_page - 1 );
# default page number
my $current_page_number = 1;
if ($offset) {