mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
fix pagination macro and add ellision
This commit is contained in:
parent
6179c3e7d4
commit
6449724ed5
@ -156,34 +156,36 @@
|
||||
</nav>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro paginate_jinja(page, nb_pages) %}
|
||||
{% macro paginate_jinja(current_page, paginator) %}
|
||||
<nav class="pagination">
|
||||
{% if page <= 1 %}
|
||||
<button disabled="disabled"><i class="fa fa-caret-left"></i></button>
|
||||
{% else %}
|
||||
<a href="?href={{ page - 1 }}">
|
||||
{% if current_page.has_previous() %}
|
||||
<a href="?page={{ current_page.previous_page_number() }}">
|
||||
<button>
|
||||
<i class="fa fa-caret-left"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% else %}
|
||||
<button disabled="disabled"><i class="fa fa-caret-left"></i></button>
|
||||
{% endif %}
|
||||
{% for i in range(1, nb_pages + 1) %}
|
||||
{% if i == page %}
|
||||
{% for i in paginator.get_elided_page_range(current_page.number) %}
|
||||
{% if i == current_page.number %}
|
||||
<button class="active">{{ i }}</button>
|
||||
{% elif i == paginator.ELLIPSIS %}
|
||||
<strong>{{ paginator.ELLIPSIS }}</strong>
|
||||
{% else %}
|
||||
<a href="?page={{ i }}">
|
||||
<button>{{ i }}</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if page >= nb_pages %}
|
||||
<button disabled="disabled"><i class="fa fa-caret-right"></i></button>
|
||||
{% else %}
|
||||
<a href="?href={{ page - 1 }}">
|
||||
{% if current_page.has_next() %}
|
||||
<a href="?page={{ current_page.next_page_number() }}">
|
||||
<button>
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% else %}
|
||||
<button disabled="disabled"><i class="fa fa-caret-right"></i></button>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% endmacro %}
|
||||
|
@ -28,7 +28,7 @@
|
||||
</p>
|
||||
|
||||
{{ display_search_bar(request) }}
|
||||
{{ paginate_jinja(msgs.number, msgs.paginator.num_pages) }}
|
||||
{{ paginate_jinja(msgs, msgs.paginator) }}
|
||||
|
||||
<main class="message-list">
|
||||
{% for m in msgs %}
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
<p><a class="ib button" href="{{ url('forum:new_message', topic_id=topic.id) }}">{% trans %}Reply{% endtrans %}</a></p>
|
||||
|
||||
{{ paginate_jinja(msgs.number, msgs.paginator.num_pages) }}
|
||||
{{ paginate_jinja(msgs, msgs.paginator) }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user