feat(FastAPI): add templates/partials/widgets/pager.html

A pager that can be used for paginated result tables.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-09-15 11:31:55 -07:00
parent 741cbfaa4e
commit 6298b1228a
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
2 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,26 @@
{# A pager widget that can be used for navigation of a number of results.
Inputs required:
prefix: Request URI prefix used to produce navigation offsets
singular: Singular sentence to be translated via tn
plural: Plural sentence to be translated via tn
PP: The number of results per page
O: The current offset value
total: The total number of results
#}
{% set page = ((O / PP) | int) %}
{% set pages = ((total / PP) | ceil) %}
<div class="pkglist-stats">
<p>
{{ total | tn(singular, plural) | format(total) }}
{{ "Page %d of %d." | tr | format(page + 1, pages) }}
</p>
{% if pages > 1 %}
<p class="pkglist-nav">
{{ page | pager_nav(total, prefix) | safe }}
<p>
{% endif %}
</div>