Bug 28453: Update pagination subroutine to generate Bootstrap markup

This patch modifies Output.pm to change the HTML it generates when
creating pagination bars. The changes allow the pagination menu to be
styled like Bootstrap pagination, making them consistent with the
pagination on catalog search results.

To test, apply the patch and rebuild the staff interface CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

 - Test pages where the pagination_bar subroutine is called:
 - Authorities -> Authority search results.
 - Cataloging -> Cataloging search results.
 - Cataloging -> MARC Editor -> Edit tag which is configured to use the
   unimarc_field_210c value builder.
 - Reports -> Saved SQL reports -> Results.
 - Tools -> Comments.
 - Lists -> List contents.

The pagination bar markup was removed from the templates for these pages
because it wasn't being used:

 - Administration -> Patron attribute types.
 - Administration -> Record matching rules.
 - Tools -> Tags.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2024-06-14 18:06:15 +00:00 committed by Katrin Fischer
parent d734a119c2
commit 2685ac2c6c
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
10 changed files with 61 additions and 70 deletions

View File

@ -109,13 +109,19 @@ sub pagination_bar {
# navigation bar useful only if more than one page to display !
if ( $nb_pages > 1 ) {
$pagination_bar = '<ul class="pagination">';
# link to first page?
if ( $current_page > 1 ) {
$pagination_bar .=
"\n" . '&nbsp;' . '<a href="' . $url . '1' . $url_suffix . '"rel="start">' . '&lt;&lt;' . '</a>';
} else {
$pagination_bar .= "\n" . '&nbsp;<span class="inactive">&lt;&lt;</span>';
"\n"
. ''
. '<li class="page-item"><a class="page-link output first" href="'
. $url . '1'
. $url_suffix
. '"rel="start">'
. '<i class="fa fa-fw fa-angle-double-left"></i> First'
. '</a></li>';
}
# link on previous page ?
@ -123,9 +129,15 @@ sub pagination_bar {
my $previous = $current_page - 1;
$pagination_bar .=
"\n" . '&nbsp;' . '<a href="' . $url . $previous . $url_suffix . '" rel="prev">' . '&lt;' . '</a>';
} else {
$pagination_bar .= "\n" . '&nbsp;<span class="inactive">&lt;</span>';
"\n"
. ''
. '<li class="page-item"><a class="page-link output previous" href="'
. $url
. $previous
. $url_suffix
. '" rel="prev">'
. '<i class="fa fa-fw fa-angle-left"></i> Previous'
. '</a></li>';
}
my $min_to_display = $current_page - $pages_around;
@ -143,20 +155,26 @@ sub pagination_bar {
if ( defined $last_displayed_page
and $last_displayed_page != $page_number - 1 )
{
$pagination_bar .= "\n" . '&nbsp;<span class="inactive">...</span>';
$pagination_bar .= "\n" . '<li class="page-item disabled"><a class="page-link">...</a></li>';
}
if ( $page_number == $current_page ) {
$pagination_bar .= "\n" . '&nbsp;' . '<span class="currentPage">' . $page_number . '</span>';
$pagination_bar .=
"\n"
. ''
. '<li class="page-item active" aria-current="page"><a class="page-link" href="#">'
. $page_number
. '</a></li>';
} else {
$pagination_bar .=
"\n"
. '&nbsp;'
. '<a href="'
. ''
. '<li class="page-item"><a class="page-link" href="'
. $url
. $page_number
. $url_suffix . '">'
. $page_number . '</a>';
. $page_number
. '</a></li>';
}
$last_displayed_page = $page_number;
}
@ -166,19 +184,29 @@ sub pagination_bar {
if ( $current_page < $nb_pages ) {
my $next = $current_page + 1;
$pagination_bar .=
"\n" . '&nbsp;<a href="' . $url . $next . $url_suffix . '" rel="next">' . '&gt;' . '</a>';
} else {
$pagination_bar .= "\n" . '&nbsp;<span class="inactive">&gt;</span>';
$pagination_bar .= "\n"
. '<li class="page-item"><a class="page-link output next" href="'
. $url
. $next
. $url_suffix
. '" rel="next">'
. 'Next <i class="fa fa-fw fa-angle-right"></i>'
. '</a></li>';
}
# link to last page?
if ( $current_page != $nb_pages ) {
$pagination_bar .=
"\n" . '&nbsp;<a href="' . $url . $nb_pages . $url_suffix . '" rel="last">' . '&gt;&gt;' . '</a>';
} else {
$pagination_bar .= "\n" . '&nbsp;<span class="inactive">&gt;&gt;</span>';
$pagination_bar .= "\n"
. '<li class="page-item"><a class="page-link output last" href="'
. $url
. $nb_pages
. $url_suffix
. '" rel="last">'
. 'Last <i class="fa fa-fw fa-angle-double-right"></i>'
. '</a></li>';
}
$pagination_bar .= "\n" . '</ul>';
}
return $pagination_bar;

View File

@ -694,42 +694,6 @@ div {
}
}
&.pages {
margin: .5em 0;
a {
font-weight: bold;
padding: 1px 5px;
text-decoration: none;
&:link,
&:visited {
background-color: #EEEEEE;
color: #3366CC;
}
&:hover,
&:active {
background-color: #FFC;
}
}
.current,
.currentPage {
background-color: #E6FCB7;
color: #666;
font-weight: bold;
padding: 1px 5px;
}
.inactive {
background-color: #F3F3F3;
color: #BCBCBC;
font-weight: bold;
padding: 1px 5px;
}
}
.browse {
margin: .5em 0;
}

View File

@ -611,8 +611,6 @@
[% ELSE %]
<p>There are no saved matching rules.</p>
[% END # /IF ( available_matching_rules ) %]
<div class="pages">[% pagination_bar | $raw %]</div>
[% END # /IF ( display_list ) %]
[% IF ( matching_rule_form ) %]

View File

@ -384,8 +384,6 @@
[% ELSE %]
<p>There are no saved patron attribute types.</p>
[% END %]
<div class="pages">[% pagination_bar | $raw %]</div>
[% END %]
[% END %]
[% MACRO jsinclude BLOCK %]

View File

@ -54,7 +54,7 @@
[% END %]
[% IF ( total ) %]
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_top"> [% pagination_bar | $raw %] </nav>
<p id="authorities_searchresultlist_current_page_info"> Results [% from | html %] to [% to | html %] of [% total | html %] </p>
@ -146,7 +146,7 @@
[% INCLUDE 'authority-detail-modal.inc' %]
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </nav>
[% ELSE %]
No results found
[% END %]

View File

@ -102,7 +102,7 @@
[% total | html %] result(s) found in catalog,
<a href="#searchresult-breeding">[% breeding_count | html %] result(s) found in reservoir</a>
</div>
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_top"> [% pagination_bar | $raw %] </nav>
<div class="searchresults">
<table>
<tr>
@ -196,7 +196,7 @@
</tr>
[% END # /FOREACH resultsloo %]
</table>
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </nav>
</div>
<!-- /.searchresults -->
</div>

View File

@ -50,7 +50,7 @@
</form>
[% IF ( total ) %]
<h3>Authority search results</h3>
<div class="pages"> [% pagination_bar | $raw %] </div>
<nav class="pages" id="pagination_top"> [% pagination_bar | $raw %] </nav>
[% END %]
<p>
[% IF ( total ) %]
@ -86,7 +86,7 @@
[% END %]
[% IF ( total ) %]
<div class="pages"> [% pagination_bar | $raw %] </div>
<nav class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </nav>
[% END %]
<!-- Authority details modal -->

View File

@ -1246,7 +1246,7 @@
<!-- /#toolbar.btn-toolbar -->
[% END # /IF batch operations || ( unlimited_total > 10 && limit <= 1000 ) %]
<div class="pages"> [% pagination_bar | $raw %] </div>
<nav id="pagination_top" class="pages"> [% pagination_bar | $raw %] </nav>
[% END # UNLESS ( errors ) %]
[% END # IF ( execute ) %]
@ -1357,7 +1357,7 @@
</tbody>
</table>
[% END %]
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </nav>
</div>
[% INCLUDE 'chart.inc' %]
[% END #/IF ( execute ) %]

View File

@ -116,7 +116,8 @@
[% END %]</tbody
>
</table>
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </nav>
[% ELSE %]
[% IF ( status ) %]<p><strong>No comments have been approved.</strong></p>[% ELSE %]<p><strong>No comments to moderate.</strong></p>[% END %]
[% END %]

View File

@ -242,7 +242,9 @@
[% IF itemsloop %]
[% SET contents = shelf.get_contents %]
[% IF ( contents.count ) %]<p>This list contains [% contents.count | html %] titles</p>[% END %]
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_top"> [% pagination_bar | $raw %] </nav>
<form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-remove_biblios" />
@ -410,7 +412,7 @@
</div>
<!-- /.page-section -->
<div class="pages">[% pagination_bar | $raw %]</div>
<nav class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </nav>
</form>
[% END # /IF itemsloop %]
[% END # /IF op == 'view' %]