mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 03:51:08 +00:00
Merge pull request #1036 from SavinaRoja/pagination-list
pagination list navigation using a range of pages such as provided by get_elided_page_range
This commit is contained in:
commit
93959fc600
2 changed files with 20 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
{% load i18n %}
|
||||
<nav class="pagination" aria-label="pagination">
|
||||
<nav class="pagination is-centered" aria-label="pagination">
|
||||
<a
|
||||
class="pagination-previous {% if not page.has_previous %}is-disabled{% endif %}"
|
||||
{% if page.has_previous %}
|
||||
|
@ -23,4 +23,18 @@
|
|||
{% trans "Next" %}
|
||||
<span class="icon icon-arrow-right" aria-hidden="true"></span>
|
||||
</a>
|
||||
|
||||
{% if page.has_other_pages and page_range %}
|
||||
<ul class="pagination-list">
|
||||
{% for num in page_range %}
|
||||
{% if num == page.number %}
|
||||
<li><a class="pagination-link is-current" aria-label="Page {{ num }}" aria-current="page">{{ num }}</a></li>
|
||||
{% elif num == '…' %}
|
||||
<li><span class="pagination-ellipsis">…</span></li>
|
||||
{% else %}
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ num }}" href="{{ path }}?{% for k, v in request.GET.items %}{% if k != 'page' %}{{ k }}={{ v }}&{% endif %}{% endfor %}page={{ num }}{{ anchor }}">{{ num }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</nav>
|
||||
|
|
|
@ -156,9 +156,13 @@ class List(View):
|
|||
).order_by("-updated_date")
|
||||
][: 5 - len(suggestions)]
|
||||
|
||||
page = paginated.get_page(request.GET.get("page"))
|
||||
data = {
|
||||
"list": book_list,
|
||||
"items": paginated.get_page(request.GET.get("page")),
|
||||
"items": page,
|
||||
"page_range": paginated.get_elided_page_range(
|
||||
page.number, on_each_side=2, on_ends=1
|
||||
),
|
||||
"pending_count": book_list.listitem_set.filter(approved=False).count(),
|
||||
"suggested_books": suggestions,
|
||||
"list_form": forms.ListForm(instance=book_list),
|
||||
|
|
Loading…
Reference in a new issue