pagination: add optional 'without_key' in template (#42441)
gitea/gadjo/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2020-05-05 13:51:26 +02:00
parent a57951805e
commit 5b4b10c81f
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 5 additions and 4 deletions

View File

@ -7,6 +7,7 @@ Expected context variables:
- page_obj: Paginator page object
- page_key (optional): name of page parameter (default: page)
- anchor (optional): anchor to use in links
- without_key (optional): key to remove in GET params
{% endcomment %}
{% if page_obj.paginator.num_pages > 1 %}
@ -15,24 +16,24 @@ Expected context variables:
<p class="paginator">
{% if page_obj.number > 1 %}
{% if page_obj.previous_page_number != 1 %}
<a href="{% querystring page_key=1 %}{{ anchor }}">1</a>
<a href="{% querystring page_key=1 without without_key %}{{ anchor }}">1</a>
{% endif %}
{% endif %}
{% if page_obj.has_previous %}
<a href="{% querystring page_key=page_obj.previous_page_number %}{{ anchor }}">{{ page_obj.previous_page_number }}</a>
<a href="{% querystring page_key=page_obj.previous_page_number without without_key %}{{ anchor }}">{{ page_obj.previous_page_number }}</a>
{% endif %}
<span class="this-page">{{ page_obj.number }}</span>
{% if page_obj.has_next %}
<a href="{% querystring page_key=page_obj.next_page_number %}{{ anchor }}">{{ page_obj.next_page_number }}</a>
<a href="{% querystring page_key=page_obj.next_page_number without without_key %}{{ anchor }}">{{ page_obj.next_page_number }}</a>
{% endif %}
{% if page_obj.number != page_obj.paginator.num_pages %}
{% if page_obj.next_page_number != page_obj.paginator.num_pages %}
<a href="{% querystring page_key=page_obj.paginator.num_pages %}{{ anchor }}">{{ page_obj.paginator.num_pages }}</a>
<a href="{% querystring page_key=page_obj.paginator.num_pages without without_key %}{{ anchor }}">{{ page_obj.paginator.num_pages }}</a>
{% endif %}
{% endif %}
</p>