-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TP2000-959 measure list pagination fix (#1026)
* Fix pagination and refactor template * Add comment * Increase per page number * Refactor context
- Loading branch information
1 parent
145db4d
commit 98262d6
Showing
2 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,119 @@ | ||
{% extends "layouts/layout.jinja" %} | ||
|
||
{% from "components/button/macro.njk" import govukButton %} | ||
{% from "components/input/macro.njk" import govukInput %} | ||
{% from "components/table/macro.njk" import govukTable %} | ||
|
||
{% set form_url = "measure-ui-list" %} | ||
{% set list_include = "includes/measures/list.jinja" %} | ||
|
||
{%- include "layouts/list_vertical.jinja" -%} | ||
{% set page_title = "Find and edit " ~ object_list.model._meta.verbose_name_plural %} | ||
|
||
|
||
{% block content %} | ||
<h1 class="govuk-heading-xl">{{ page_title }}</h1> | ||
|
||
<div class="full-width-search"> | ||
<div class="govuk-!-margin-bottom-5"> | ||
<h2 class="govuk-heading-m govuk-!-margin-bottom-5">Search and filter</h2> | ||
<p class="govuk-body"> | ||
Select one or more options to search | ||
</p> | ||
<form method="get" action="{{ url(form_url) }}"> | ||
{{ crispy(filter.form) }} | ||
</form> | ||
</div> | ||
|
||
|
||
<div class="govuk-!-margin-top-3"> | ||
{% if results_count > 0 %} | ||
|
||
{% set objects_count = '{0:,}'.format(results_count) %} | ||
{% if results_limit_breached %} | ||
{% set objects_count = objects_count ~ '+' %} | ||
{% endif %} | ||
|
||
<p class="govuk-body-l"> | ||
{{ objects_count }} results | ||
</p> | ||
|
||
{% endif %} | ||
{% if object_list %} | ||
{% include list_include %} | ||
{% else %} | ||
<p class="govuk-body">There are no results for your search, please:</p> | ||
<ul class="govuk-list govuk-list--bullet"> | ||
<li>check the spelling of your keywords</li> | ||
<li>use more general keywords</li> | ||
<li>select or deselect different filters</li> | ||
<li>get help via our <a class="govuk-link" href="#">support and feedback form</a></li> | ||
</ul> | ||
{% endif %} | ||
|
||
{% if has_other_pages %} | ||
{% set objects_count = '{0:,}'.format(results_count) %} | ||
{% set page_count = '{0:,}'.format(page_count) %} | ||
{% if results_limit_breached %} | ||
{% set objects_count = 'more than ' ~ objects_count %} | ||
{% set page_count = 'more than ' ~ page_count %} | ||
{% endif %} | ||
|
||
<nav class="pagination tamato-clearfix" role="navigation" aria-label="Pagination Navigation"> | ||
<div class="govuk-body"> | ||
Showing {{ list_items_count }} of {{ objects_count }} measures | ||
</div> | ||
<div class="govuk-body align-left"> | ||
Page {{page_number}} of {{ page_count }} | ||
</div> | ||
<ul class="govuk-list align-right"> | ||
{% if has_previous_page %} | ||
<li> | ||
<a | ||
class="govuk-link govuk-!-margin-right-1" | ||
href="?{{ query_transform(request, page=prev_page_number)}}" | ||
rel="prev" | ||
aria-label="Goto Page {{ prev_page_number }}" | ||
> | ||
Prev | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% for page_link in page_links %} | ||
{% set isCurrent = page_link == page_number%} | ||
<li | ||
class="{{ 'govuk-!-margin-left-2 govuk-!-margin-right-2' if isCurrent else 'govuk-!-margin-right-1'}}" | ||
{% if isCurrent %}aria-current="true"{% endif %} | ||
> | ||
{% if page_link == '...' or page_link == page_number|string %} | ||
{{ page_link }} | ||
{% else %} | ||
<a | ||
class="govuk-link" | ||
href="?{{ query_transform(request, page=page_link) }}" | ||
aria-label="Goto Page {{ page_link }}" | ||
>{{ '{0:,}'.format(page_link|int) }}</a> | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
{% if results_limit_breached %} | ||
<li class="govuk-!-margin-right-1" >...</li> | ||
{% endif %} | ||
{% if has_next_page %} | ||
<li> | ||
<a | ||
class="govuk-link" | ||
href="?{{ query_transform(request, page=next_page_number) }}" | ||
rel="next" | ||
aria-label="Goto Page {{ next_page_number }}" | ||
> | ||
Next | ||
</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
</nav> | ||
{% endif %} | ||
|
||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters