update listing and add pagination

This commit is contained in:
envoyr
2022-02-25 20:52:09 +01:00
parent 5964c3b685
commit 7cfdf80a14
13 changed files with 145 additions and 228 deletions

View File

@@ -0,0 +1,28 @@
{% macro paging(pagination) %}
<div class="card-footer border-top">
{% if pagination.current_page >= pagination.last_page %}
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno=1">&laquo;</a>
{% endif %}
{% if pagination.current_page >= pagination.last_page %}
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.current_page - 1 }}">&lsaquo;</a>
{% endif %}
{% if pagination.current_page < pagination.last_page %}
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.current_page + 1 }}">&rsaquo;</a>
{% endif %}
{% if pagination.current_page < pagination.last_page %}
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.last_page }}">&raquo;</a>
{% endif %}
</div>
{% endmacro %}
{% macro titlesorting(pagination, key, th) %}
{% if pagination is defined and key in pagination.sortfields %}
<th class="p-3 {{ th.class }}">
{{ th.text }}
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.current_page }}&sortfield={{ key }}&sortorder=desc">&darr;</a>
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.current_page }}&sortfield={{ key }}&sortorder=asc">&uarr;</a>
</th>
{% else %}
<th class="p-3 {{ th.class }}">{{ th.text }}</th>
{% endif %}
{% endmacro %}

View File

@@ -1,6 +1,7 @@
{% macro table(listing) %}
{% import "Froxlor/table/callbacks.html.twig" as callbacks %}
{% import "Froxlor/table/pagination.html.twig" as pagination %}
<form action="{{ action|default("") }}" method="post" enctype="application/x-www-form-urlencoded" class="form">
{% if listing.title is not empty %}
@@ -16,8 +17,8 @@
<table class="table table-borderless table-striped table-sm mb-0 px-3">
<thead>
<tr>
{% for th in listing.table.th %}
<th class="p-3 {{ th.class }}">{{ th.text }}</th>
{% for key,th in listing.table.th %}
{{ pagination.titlesorting(listing.pagination, key, th) }}
{% endfor %}
</tr>
</thead>
@@ -50,9 +51,7 @@
</tbody>
</table>
{% if listing.pagination is not empty %}
<div class="card-footer">
Pagination...
</div>
{{ pagination.paging(listing.pagination) }}
{% endif %}
</div>
</form>