[Rt-commit] rt branch 5.0/update-search-result-paging created. rt-5.0.3-226-g61664f89e9
BPS Git Server
git at git.bestpractical.com
Mon Jan 9 22:08:57 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/update-search-result-paging has been created
at 61664f89e93e428303d9e2ec4b799026f514f06a (commit)
- Log -----------------------------------------------------------------
commit 61664f89e93e428303d9e2ec4b799026f514f06a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Jan 9 17:00:58 2023 -0500
Add box to jump to search results page
diff --git a/share/html/Elements/CollectionListPaging b/share/html/Elements/CollectionListPaging
index 94b0455b40..2284a8d572 100644
--- a/share/html/Elements/CollectionListPaging
+++ b/share/html/Elements/CollectionListPaging
@@ -99,6 +99,24 @@ else{
}
}
}
-
$m->out(qq{</div>});
+
+# Clear Page before writing hidden values for the jump form
+delete $URLParams->{'Page'} if $URLParams->{'Page'};
</%INIT>
+<div class="page-jump mx-auto">
+ <form method="post" action="<%RT->Config->Get('WebPath')%>/Search/Results.html">
+% foreach my $key ( keys(%$URLParams) ) {
+<input type="hidden" class="hidden" name="<%$key%>" value="<% defined($URLParams->{$key})?$URLParams->{$key}:'' %>" />
+% }
+ <div class="form-row">
+ <div class="label col-6"><&|/l&>Jump to page</&>:</div>
+ <div class="col-4">
+ <input type="text" class="form-control" name="Page" value="" />
+ </div>
+ <div class="col-2">
+ <input type="submit" class="button btn btn-primary form-control" value="<&|/l&>Go</&>" />
+ </div>
+ </div>
+ </form>
+</div>
diff --git a/share/static/css/elevator-light/ticket-lists.css b/share/static/css/elevator-light/ticket-lists.css
index d5c9631f14..38ee1323b6 100644
--- a/share/static/css/elevator-light/ticket-lists.css
+++ b/share/static/css/elevator-light/ticket-lists.css
@@ -52,3 +52,7 @@ table.queue-summary th.collection-as-table {
li.page-item > a.rt-page-link {
color: #3858a3;
}
+
+.page-jump {
+ width: 200px;
+}
commit 17018c751d950cbbb0c9e838b3257e97ddbe13ae
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Tue Jan 3 09:44:10 2023 -0500
Update search results to use Bootstrap pagination styles
For large sets of search results, this update also replaces
the huge block of numbers with a simpler begining, middle,
end set of page numbers. This still allows navigation without
the giant list of number ranges.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 7de6dcf3fc..4c2f9ac6a1 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -5304,6 +5304,71 @@ sub GetDashboards {
return \%dashboards;
}
+=head2 BuildSearchResultPagination
+
+Accepts a Data::Page object loaded with information about a set of
+search results.
+
+Returns an array with the pages from that set to include when displaying
+pagination for those search results. This array can then be used to
+generate the desired links and other UI.
+
+=cut
+
+sub BuildSearchResultPagination {
+ my $pager = shift;
+ my @pages;
+
+ # For 10 or less, show all pages in a line, no breaks
+ if ( $pager->last_page < 11 ) {
+ for ( my $p = 1; $p <= $pager->last_page; $p++ ) {
+ push @pages, $p;
+ }
+ }
+ else {
+ # For more pages, need to insert ellipsis for breaks
+ # This creates 1 2 3...10 11 12...51 52 53
+ @pages = ( 1, 2, 3 );
+
+ if ( $pager->current_page() == 3 ) {
+ # When on page 3, show 4 so you can keep going
+ push @pages, ( 4 );
+ }
+ elsif ( $pager->current_page() == 4 ) {
+ # Handle 4 and 5 without ellipsis
+ push @pages, ( 4, 5 );
+ }
+ elsif ( $pager->current_page() == 5 ) {
+ # Handle 4 and 5 without ellipsis
+ push @pages, ( 4, 5, 6 );
+ }
+ elsif ( $pager->current_page() > 5 && $pager->current_page() < ($pager->last_page - 4) ) {
+ push @pages, ( 'ellipsis',
+ $pager->current_page() - 1, $pager->current_page(), $pager->current_page() + 1 );
+ }
+
+ push @pages, 'ellipsis';
+
+ # Add padding at the end, the reverse of the above
+ if ( $pager->current_page() == ($pager->last_page - 2) ) {
+ push @pages, $pager->last_page - 3;
+ }
+
+ if ( $pager->current_page() == ($pager->last_page - 3) ) {
+ push @pages, ( $pager->last_page - 4, $pager->last_page - 3 );
+ }
+
+ if ( $pager->current_page() == ($pager->last_page - 4) ) {
+ push @pages, ( $pager->last_page - 5, $pager->last_page - 4, $pager->last_page - 3 );
+ }
+
+ # Add the end of the list
+ push @pages, ( $pager->last_page - 2, $pager->last_page -1, $pager->last_page );
+ }
+
+ return @pages;
+}
+
package RT::Interface::Web;
RT::Base->_ImportOverlays();
diff --git a/share/html/Elements/CollectionListPaging b/share/html/Elements/CollectionListPaging
index 1ba778c499..94b0455b40 100644
--- a/share/html/Elements/CollectionListPaging
+++ b/share/html/Elements/CollectionListPaging
@@ -60,51 +60,44 @@ $BaseURL = $m->interp->apply_escapes($BaseURL, 'h');
$m->out(qq{<div class="paging">});
if ($Pages == 1) {
- $m->out(loc('Page 1 of 1'));
+ $m->out(loc('Page 1 of 1'));
}
else{
- $m->out(loc('Page') . ' ');
+ $m->out(qq{<ul class="pagination justify-content-center">});
+ use Data::Page;
- use Data::Page;
- use Data::Page::Pageset;
+ my $pager = Data::Page->new();
+ $pager->total_entries($TotalFound);
+ $pager->entries_per_page($Rows);
+ $pager->current_page($CurrentPage);
- my $pager = Data::Page->new();
- $pager->total_entries($TotalFound);
- $pager->entries_per_page($Rows);
- $pager->current_page($CurrentPage);
- my $pageset = Data::Page::Pageset->new($pager);
+ my @pages = BuildSearchResultPagination( $pager );
- for my $chunk ( $pageset->total_pagesets ) {
- $m->out(qq{<span class="pagenum">});
- if ( $chunk->is_current ) {
- for my $number ( $chunk->first .. $chunk->last ) {
- if ( $number == $CurrentPage ) {
- $m->out(qq{<span class="currentpage">$number</span> });
- }
- else {
- my $qs = $m->interp->apply_escapes(
+ foreach my $page ( @pages ) {
+
+ my $active_item = '';
+ $active_item = " active" if ( $page =~ /^\d+/ && $page == $pager->current_page() );
+
+ if ( $page eq 'ellipsis' ) {
+ $m->out(qq{<li class="page-item disabled">});
+ $m->out(qq{<a class="page-link" href="#" tabindex="-1">...</a>});
+ $m->out(qq{</li>});
+ next;
+ }
+ else {
+ # Build the link
+ my $query_string = $m->interp->apply_escapes(
$m->comp('/Elements/QueryString',
- %$URLParams,
- $PageParam => $number
- ),
+ %$URLParams,
+ $PageParam => $page, ),
'h',
- );
- $m->out(qq{<a href="$BaseURL$qs">$number</a> });
- }
+ );
+
+ $m->out(qq{<li class="page-item$active_item">});
+ $m->out(qq{<a class="page-link rt-page-link" href="$BaseURL$query_string">$page</a>});
+ $m->out(qq{</li>});
}
- } else {
- my $qs = $m->interp->apply_escapes(
- $m->comp('/Elements/QueryString',
- %$URLParams,
- $PageParam => $chunk->first,
- ),
- 'h',
- );
- $m->out(qq{<a href="$BaseURL$qs">$chunk</a>});
}
- $m->out(qq{</span>});
- }
-
}
$m->out(qq{</div>});
diff --git a/share/static/css/elevator-light/misc.css b/share/static/css/elevator-light/misc.css
index 6e1d5c0e0a..6a047883ef 100644
--- a/share/static/css/elevator-light/misc.css
+++ b/share/static/css/elevator-light/misc.css
@@ -142,11 +142,6 @@ h1#transaction-extra-info {
padding-top: 0.4rem;
}
-/* Prevent page links from running off the side of the page for Firefox */
-span.pagenum {
- display: inline-block;
-}
-
/* Do not change background color on click of dropdown items like "Show
* full headers" in ticket history */
.btn-group.dropdown .dropdown-item:active {
diff --git a/share/static/css/elevator-light/ticket-lists.css b/share/static/css/elevator-light/ticket-lists.css
index cd30418fec..d5c9631f14 100644
--- a/share/static/css/elevator-light/ticket-lists.css
+++ b/share/static/css/elevator-light/ticket-lists.css
@@ -49,19 +49,6 @@ table.queue-summary th.collection-as-table {
vertical-align: middle;
}
-.pagenum *,
-.paging a.nav {
- padding: .5em;
-}
-
-.currentpage {
- text-decoration: none;
- font-weight: bold;
- background: #eee;
-}
-
-div.paging {
- font-size: 1.07em;
- text-align: center;
- padding-bottom: 1em;
+li.page-item > a.rt-page-link {
+ color: #3858a3;
}
commit 7e05402d2033151bd3f568a59ba6ccadb640f48f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Jan 5 14:15:48 2023 -0500
Convert to preferred constructor for Data::Page
The documentation for Data::Page says the constructor that
accepts arguments is deprecated, so switch to using the
provided methods to set page data on the pager object.
diff --git a/share/html/Elements/CollectionListPaging b/share/html/Elements/CollectionListPaging
index 766e41d57d..1ba778c499 100644
--- a/share/html/Elements/CollectionListPaging
+++ b/share/html/Elements/CollectionListPaging
@@ -68,7 +68,10 @@ else{
use Data::Page;
use Data::Page::Pageset;
- my $pager = Data::Page->new($TotalFound, $Rows, $CurrentPage);
+ my $pager = Data::Page->new();
+ $pager->total_entries($TotalFound);
+ $pager->entries_per_page($Rows);
+ $pager->current_page($CurrentPage);
my $pageset = Data::Page::Pageset->new($pager);
for my $chunk ( $pageset->total_pagesets ) {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list