Refactor pagination macro
This commit is contained in:
parent
16febc2a77
commit
eff797d21b
@ -18,13 +18,30 @@
|
|||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
|
||||||
{% if pagination.page == 1 %}
|
{% if pagination.page == 1 %}
|
||||||
{% set max_page = [pagination.pages, 5] | min %}
|
|
||||||
{{ Page(pagination, route, 1, label="first", disabled=True, workspace_id=workspace_id) }}
|
{{ Page(pagination, route, 1, label="first", disabled=True, workspace_id=workspace_id) }}
|
||||||
{{ Page(pagination, route, pagination.page - 1, label="prev", disabled=True, workspace_id=workspace_id) }}
|
{{ Page(pagination, route, pagination.page - 1, label="prev", disabled=True, workspace_id=workspace_id) }}
|
||||||
|
{% else %}
|
||||||
|
{{ Page(pagination, route, 1, label="first", workspace_id=workspace_id) }}
|
||||||
|
{{ Page(pagination, route, pagination.page - 1, label="prev", workspace_id=workspace_id) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if pagination.page == 1 %}
|
||||||
|
{% set max_page = [pagination.pages, 5] | min %}
|
||||||
{% for i in range(1, max_page + 1) %}
|
{% for i in range(1, max_page + 1) %}
|
||||||
{{ Page(pagination, route, i, workspace_id=workspace_id) }}
|
{{ Page(pagination, route, i, workspace_id=workspace_id) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pagination.per_page >= pagination.total %}
|
{% elif pagination.page == pagination.pages %}
|
||||||
|
{% for i in range(pagination.pages - 4, pagination.pages + 1) %}
|
||||||
|
{{ Page(pagination, route, i, workspace_id=workspace_id) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% set window = pagination | pageWindow %}
|
||||||
|
{% for i in range(window.0, window.1 + 1) %}
|
||||||
|
{{ Page(pagination, route, i, workspace_id=workspace_id) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if pagination.page == pagination.pages %}
|
||||||
{{ Page(pagination, route, pagination.page + 1, label="next", disabled=True, workspace_id=workspace_id) }}
|
{{ Page(pagination, route, pagination.page + 1, label="next", disabled=True, workspace_id=workspace_id) }}
|
||||||
{{ Page(pagination, route, pagination.pages, label="last", disabled=True, workspace_id=workspace_id) }}
|
{{ Page(pagination, route, pagination.pages, label="last", disabled=True, workspace_id=workspace_id) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -32,23 +49,5 @@
|
|||||||
{{ Page(pagination, route, pagination.pages, label="last", workspace_id=workspace_id) }}
|
{{ Page(pagination, route, pagination.pages, label="last", workspace_id=workspace_id) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% elif pagination.page == pagination.pages %}
|
|
||||||
{{ Page(pagination, route, 1, label="first", workspace_id=workspace_id) }}
|
|
||||||
{{ Page(pagination, route, pagination.page - 1, label="prev", workspace_id=workspace_id) }}
|
|
||||||
{% for i in range(pagination.pages - 4, pagination.pages + 1) %}
|
|
||||||
{{ Page(pagination, route, i, workspace_id=workspace_id) }}
|
|
||||||
{% endfor %}
|
|
||||||
{{ Page(pagination, route, pagination.page + 1, label="next", disabled=True, workspace_id=workspace_id) }}
|
|
||||||
{{ Page(pagination, route, pagination.pages, label="last", disabled=True, workspace_id=workspace_id) }}
|
|
||||||
{% else %}
|
|
||||||
{% set window = pagination | pageWindow %}
|
|
||||||
{{ Page(pagination, route, 1, label="first", workspace_id=workspace_id) }}
|
|
||||||
{{ Page(pagination, route, pagination.page - 1, label="prev", workspace_id=workspace_id) }}
|
|
||||||
{% for i in range(window.0, window.1 + 1) %}
|
|
||||||
{{ Page(pagination, route, i, workspace_id=workspace_id) }}
|
|
||||||
{% endfor %}
|
|
||||||
{{ Page(pagination, route, pagination.page + 1, label="next", workspace_id=workspace_id) }}
|
|
||||||
{{ Page(pagination, route, pagination.pages, label="last", workspace_id=workspace_id) }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user