A few paging changes...

Pass the items name (plural) into the page nav partial.
Simplify what's shown if there's no more than one pageful of items.
This commit is contained in:
barnold 2022-09-19 13:25:50 +01:00
parent be0b5673de
commit 3c2dd9eac5
4 changed files with 18 additions and 16 deletions

View File

@ -11,8 +11,8 @@ $t->get_ok('/account')->status_is(302);
$t->get_ok('/auth')->status_is(200)->content_like(qr/login/i);
$t->post_ok('/login' => form => { logname => 'Dobby' });
$t->get_ok('/account')->status_is(200)->content_like(qr/dobby/i);
$t->get_ok('/books/1')->status_is(200)->content_like(qr/[[:digit:]] books found/i);
$t->get_ok('/authors/1')->status_is(200)->content_like(qr/[[:digit:]] authors found/i);
$t->get_ok('/books/1')->status_is(200)->content_like(qr/[[:digit:]] books/i);
$t->get_ok('/authors/1')->status_is(200)->content_like(qr/[[:digit:]] authors/i);
$t->get_ok('/logout')->status_is(302);
# Can't do "content_unlike()" so check it offers login now.
$t->get_ok('/')->status_is(200)->content_like(qr/login/i);

View File

@ -1,9 +1,13 @@
<p/>
Showing <%= $pager->entries_on_this_page %> items
Showing <%= $pager->entries_on_this_page %> <%= $items_name || "items" %>
of
<%= commify($pager->total_entries) =%>
% if ($pager->total_entries <= rpp) {
.
<% } else { %>
on page <%= commify($pager->current_page) %>
of <%= commify($pager->last_page) %>
of <%= commify($pager->last_page) %>.
<% if ($pager->total_entries > rpp) { %>
<br/>
<%= link_to url_with(page_number => 1) => begin %>◄ First<% end %>
@ -20,4 +24,4 @@ Next ►
% }
<%= link_to url_with(page_number => $pager->last_page) => begin %>Last ►<% end %>
<% } %>
% }

View File

@ -1,6 +1,6 @@
% layout 'default';
% title 'Authors';
<h1>Authors</h1>
<h1><%= title %></h1>
<%# On a new search, reset the page number to 1. %>
%= form_for authors => { page_number => 1 } => begin
@ -9,9 +9,7 @@
%= submit_button "Search"
%= end
<p/>
<%= commify($pager->total_entries) %> authors found.
% if ($pager->total_entries > 0) {
<p/>
<div>
<table>
@ -27,5 +25,6 @@
% }
</table>
</div>
% }
%= include '_page-navigation'
%= include '_page-navigation', items_name => 'authors'

View File

@ -1,6 +1,6 @@
% layout 'default';
% title 'Books';
<h1>Books</h1>
<h1><%= title %></h1>
<%# On a new search, reset the page number to 1. %>
%= form_for books => { page_number => 1 } => begin
@ -9,9 +9,7 @@
%= submit_button "Search"
%= end
<p/>
<%= commify($pager->total_entries) %> books found.
% if ($pager->total_entries > 0) {
<p/>
<div>
<table>
@ -28,5 +26,6 @@
% }
</table>
</div>
% }
%= include '_page-navigation'
%= include '_page-navigation', items_name => 'books';