Bug 30745: Display pagination for the results page

I have fixed the pagination issue when the search returns multiple results.

Test plan:
    - Enable elasticsearch
    - git to labels/label-item-search.pl
    - search using after date only
            => check you get items with date-of-acquisition greater than after
date
    - search using before date only
            => check you get items with date-of-acquisition less than before
date
    - search using after and before date
            => check you get items with date-of-acquisition between after and
before
    - Combine this searches with a specified index
    - enable zebra and repeat these tests
pagination tests
    - Perform a search that returns more than 20 notices
    - Navigate through different result pages using page numbers, the "Next" button, and the "Previous" button
	    => On each page, check that "Results X through X of X" displays the correct information

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Emily-Rose Francoeur 2023-10-26 11:28:35 -04:00 committed by Katrin Fischer
parent b06e648de7
commit b17df14745
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 17 additions and 19 deletions

View file

@ -6,7 +6,7 @@
<ul class="pagination">
[% IF ( displayprev ) %]
<li class="page-item">
<a class="page-link" href="label-item-search.pl?startfrom=[% startfromprev | html %]&amp;ccl_query=[% ccl_query | html %]&amp;resultsperpage=[% resultsperpage | html %]&amp;op=do_search&amp;batch_id=[% batch_id | html %]"><i class="fa fa-arrow-left"></i> Previous</a>
<a class="page-link" href="label-item-search.pl?startfrom=[% startfromprev | html %]&amp;idx=[% idx | html %]&amp;resultsperpage=[% resultsperpage | html %]&amp;op=do_search&amp;batch_id=[% batch_id | html %]&amp;ccl_textbox=[% ccl_textbox | html %]&amp;limits=[% limits | html %]"><i class="fa fa-arrow-left"></i> Previous</a>
</li>
[% END %]
[% FOREACH number IN numbers %]
@ -16,13 +16,13 @@
</li>
[% ELSE %]
<li class="page-item">
<a class="page-link" href="label-item-search.pl?startfrom=[% number.startfrom | html %]&amp;ccl_query=[% ccl_query | html %]&amp;resultsperpage=[% resultsperpage | html %]&amp;op=do_search&amp;batch_id=[% batch_id | html %]">[% number.number | html %]</a>
<a class="page-link" href="label-item-search.pl?startfrom=[% number.startfrom | html %]&amp;idx=[% idx | html %]&amp;resultsperpage=[% resultsperpage | html %]&amp;op=do_search&amp;batch_id=[% batch_id | html %]&amp;ccl_textbox=[% ccl_textbox | html %]&amp;limits=[% limits | html %]">[% number.number | html %]</a>
</li>
[% END %]
[% END %]
[% IF ( displaynext ) %]
<li class="page-item">
<a class="page-link" href="label-item-search.pl?startfrom=[% startfromnext | html %]&amp;ccl_query=[% ccl_query | html %]&amp;resultsperpage=[% resultsperpage | html %]&amp;op=do_search&amp;batch_id=[% batch_id | html %]">Next <i class="fa fa-arrow-right"></i></a>
<a class="page-link" href="label-item-search.pl?startfrom=[% startfromnext | html %]&amp;idx=[% idx | html %]&amp;resultsperpage=[% resultsperpage | html %]&amp;op=do_search&amp;batch_id=[% batch_id | html %]&amp;ccl_textbox=[% ccl_textbox | html %]&amp;limits=[% limits | html %]">Next <i class="fa fa-arrow-right"></i></a>
</li>
[% END %]
</ul>
@ -60,7 +60,6 @@
</div>
<div id="label-search-results" class="page-section">
<input type="hidden" name="ccl_query" value="[% ccl_query | html %]" />
[% FOREACH result_se IN result_set %]
<div style="border-bottom:1px solid #CCC;padding:1em 0;">
<h4>[% result_se.title | html %]</h4>

View file

@ -40,7 +40,7 @@ my $query = CGI->new;
my $type = $query->param('type');
my $op = $query->param('op') || '';
my $batch_id = $query->param('batch_id');
my $ccl_query = $query->param('ccl_query');
my @limits = split(" AND ", $query->param('limits') || "");
my $startfrom = $query->param('startfrom') || 1;
my ($template, $loggedinuser, $cookie) = (undef, undef, undef);
my (
@ -68,13 +68,9 @@ if ( $op eq "do_search" ) {
my $searcher = Koha::SearchEngine::Search->new(
{ index => $Koha::SearchEngine::BIBLIOS_INDEX } );
my @limits;
if ($datefrom) {
push(@limits, "acqdate,ge,st-date-normalized=$datefrom");
}
if ($dateto) {
push(@limits, "acqdate,le,st-date-normalized=$dateto");
if (!@limits) {
push(@limits, "acqdate,ge,st-date-normalized=$datefrom") if ($datefrom);
push(@limits, "acqdate,le,st-date-normalized=$dateto") if ($dateto);
}
my ( $build_error, $query, $simple_query, $query_cgi,
@ -90,8 +86,9 @@ if ( $op eq "do_search" ) {
);
if (!defined $error && @{$results->{biblioserver}{RECORDS}} ) {
$show_results = @{$results->{biblioserver}{RECORDS}};
$marcresults = $results->{biblioserver}{RECORDS};
$show_results = grep { defined $_ } @{$results->{biblioserver}{RECORDS}};
$marcresults = [ grep { defined $_ } @{$results->{biblioserver}{RECORDS}} ];
$total_hits = $results->{biblioserver}{hits};
}
else {
Koha::Logger->get->warn("ERROR label-item-search: no results from simple_search_compat");
@ -196,11 +193,13 @@ if ($show_results) {
);
$template->param(
results => ($show_results ? 1 : 0),
result_set=> \@results_set,
batch_id => $batch_id,
type => $type,
ccl_query => $ccl_query,
results => ($show_results ? 1 : 0),
result_set => \@results_set,
batch_id => $batch_id,
type => $type,
idx => $idx,
ccl_textbox => $ccl_textbox,
limits => join(" AND ", @limits),
);
}