rDrama/files/templates/pagination.html

65 lines
1.9 KiB
HTML
Raw Normal View History

2023-05-04 22:15:13 +00:00
<nav>
2024-03-02 22:25:52 +00:00
<ul class="pagination pagination-sm mb-0 {% if request.path.endswith('/bank_statement') %}pb-0 pl-0 pt-1{% else %}pl-1 mt-4{% endif %}">
{% if not size %}
{% set size = PAGE_SIZE %}
{% endif %}
{% set num_pages = (total / size) | round(0, 'ceil') | int %}
2023-05-04 22:15:13 +00:00
2023-09-29 01:52:14 +00:00
{% set start_point = page - 2 %}
{% if start_point < 1 %}
{% set start_point = 1 %}
2023-05-04 22:15:13 +00:00
{% endif %}
2023-09-29 01:52:14 +00:00
{% set end_point = start_point+4 %}
2023-05-04 22:15:13 +00:00
{% if end_point > num_pages %}
2023-09-29 01:52:14 +00:00
{% set start_point = start_point-(end_point-num_pages) %}
2023-05-04 22:15:13 +00:00
{% set end_point = num_pages %}
{% endif %}
2023-09-29 01:52:14 +00:00
{% if start_point < 1 %}
{% set start_point = 1 %}
2023-05-04 22:15:13 +00:00
{% endif %}
2023-09-29 01:52:14 +00:00
{% if start_point > 1 %}
2023-05-04 22:15:13 +00:00
<li class="page-item">
2023-09-05 14:32:36 +00:00
<small><a class="page-link" href="{{'page'|change_arg(1, request.full_path)|safe}}">1</a></small>
2023-05-04 22:15:13 +00:00
</li>
2023-09-29 01:52:14 +00:00
{% if start_point == 3 %}
2023-05-04 22:15:13 +00:00
<li class="page-item">
2023-09-05 14:32:36 +00:00
<small><a class="page-link" href="{{'page'|change_arg(2, request.full_path)|safe}}">2</a></small>
2023-05-04 22:15:13 +00:00
</li>
2023-09-29 01:52:14 +00:00
{% elif start_point != 2 %}
2023-05-04 22:15:13 +00:00
<li class="page-item">
<small class="page-link dots">...</small>
</li>
2023-09-29 01:52:14 +00:00
{% set start_point = start_point + 1 %}
2023-05-04 22:15:13 +00:00
{% endif %}
{% endif %}
2023-09-29 01:52:14 +00:00
{% for x in range(start_point, end_point+1) %}
2023-05-04 22:15:13 +00:00
<li class="page-item">
2023-09-05 14:32:36 +00:00
<small><a class="page-link {% if x == page %}active disabled{% endif %}" href="{{'page'|change_arg(x, request.full_path)|safe}}">{{x}}</a></small>
2023-05-04 22:15:13 +00:00
</li>
{% endfor %}
{% if end_point < num_pages %}
{% if end_point == num_pages-2 %}
<li class="page-item">
2023-09-05 14:32:36 +00:00
<small><a class="page-link" href="{{'page'|change_arg(num_pages-1, request.full_path)|safe}}">{{num_pages-1}}</a></small>
2023-05-04 22:15:13 +00:00
</li>
{% elif end_point != num_pages-1 %}
<li class="page-item">
<small class="page-link dots">...</small>
</li>
{% endif %}
<li class="page-item">
2023-09-05 14:32:36 +00:00
<small><a class="page-link" href="{{'page'|change_arg(num_pages, request.full_path)|safe}}">{{num_pages}}</a></small>
2023-05-04 22:15:13 +00:00
</li>
{% endif %}
</ul>
</nav>