admin: fix pagination template, ensure template is placed correctly in footer

This commit is contained in:
Jens Langhammer 2020-10-03 17:50:17 +02:00
parent 801bb90806
commit b35d27c83e
19 changed files with 67 additions and 55 deletions

View File

@ -62,7 +62,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -64,7 +64,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -69,7 +69,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -61,7 +61,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -83,7 +83,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -78,7 +78,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -75,7 +75,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -72,7 +72,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -91,7 +91,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -85,7 +85,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -81,7 +81,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -81,7 +81,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -54,7 +54,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -80,7 +80,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -65,7 +65,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -61,7 +61,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
{% else %} {% else %}

View File

@ -77,7 +77,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom"> <div class="pf-c-pagination pf-m-bottom">
{% include 'partials/pagination.html' %} {% include 'partials/pagination.html' %}
</div> </div>
</div> </div>

View File

@ -1,43 +1,42 @@
{% load i18n %} {% load i18n %}
{% load passbook_utils %}
<div class="pf-c-toolbar__item pf-m-pagination "> <div class="pf-c-toolbar__item pf-m-pagination ">
<div class="pf-c-pagination"> <div class="pf-c-pagination pf-m-compact pf-m-hidden pf-m-visible-on-md">
<div class="pf-c-pagination__total-items"> <div class="pf-c-pagination pf-m-compact pf-m-compact pf-m-hidden pf-m-visible-on-md">
<b>{{ page_obj.start_index }} - {{ page_obj.end_index }}</b>of <div class="pf-c-options-menu">
<b>{{ page_obj.count }}</b> <div class="pf-c-options-menu__toggle pf-m-text pf-m-plain">
</div> <span class="pf-c-options-menu__toggle-text">
{% with param=get_param|default:'page' %} {% blocktrans with start_index=page_obj.start_index end_index=page_obj.end_index total_items=paginator.count %}
<nav class="pf-c-pagination__nav" aria-label="Pagination"> {{ start_index }} - {{ end_index }} of {{ total_items }}
<a class="pf-c-button pf-m-plain" type="button" aria-label="Go to first page" href="?{{ param }}=1">
<i class="fas fa-angle-double-left" aria-hidden="true"></i>
</a>
<a class="pf-c-button pf-m-plain" type="button" aria-label="Go to previous page"
{% if page_obj.has_previous %}
href="?{{ param }}={{ page_obj.previous_page_number }}"
{% else %}
disabled
{% endif %}>
<i class="fas fa-angle-left" aria-hidden="true"></i>
</a>
<div class="pf-c-pagination__nav-page-select">
<span>
{% blocktrans with current=page_obj.number total=page_obj.paginator.num_pages %}
{{ current }} of {{ total }}
{% endblocktrans %} {% endblocktrans %}
</span> </span>
</div> </div>
<a class="pf-c-button pf-m-plain" type="button" aria-label="Go to next page" </div>
{% if page_obj.has_next %} <nav class="pf-c-pagination__nav" aria-label="Pagination">
href="?{{ param }}={{ page_obj.next_page_number }}" <div class="pf-c-pagination__nav-control pf-m-prev">
<a class="pf-c-button pf-m-plain"
{% if page_obj.has_previous %}
href="?{% query_transform page=page_obj.previous_page_number %}"
{% else %} {% else %}
disabled disabled
{% endif %}> {% endif %}
aria-label="{% trans 'Go to previous page' %}">
<i class="fas fa-angle-left" aria-hidden="true"></i>
</a>
</div>
<div class="pf-c-pagination__nav-control pf-m-next">
<a class="pf-c-button pf-m-plain"
{% if page_obj.has_next %}
href="?{% query_transform page=page_obj.next_page_number %}"
{% else %}
disabled
{% endif %}
aria-label="{% trans 'Go to next page' %}">
<i class="fas fa-angle-right" aria-hidden="true"></i> <i class="fas fa-angle-right" aria-hidden="true"></i>
</a> </a>
<a class="pf-c-button pf-m-plain" type="button" aria-label="Go to last page" href="?{{ param }}={{ page_obj.num_pages }}"> </div>
<i class="fas fa-angle-double-right" aria-hidden="true"></i>
</a>
</nav> </nav>
{% endwith %} </div>
</div> </div>
</div> </div>

View File

@ -4,6 +4,7 @@ from urllib.parse import urlencode
from django import template from django import template
from django.db.models import Model from django.db.models import Model
from django.http.request import HttpRequest
from django.template import Context from django.template import Context
from django.utils.html import escape, mark_safe from django.utils.html import escape, mark_safe
from structlog import get_logger from structlog import get_logger
@ -115,3 +116,15 @@ def debug(obj) -> str:
def doc(obj) -> str: def doc(obj) -> str:
"""Return docstring of object""" """Return docstring of object"""
return mark_safe(obj.__doc__.replace("\n", "<br>")) return mark_safe(obj.__doc__.replace("\n", "<br>"))
@register.simple_tag(takes_context=True)
def query_transform(context: Context, **kwargs) -> str:
"""Append objects to the current querystring"""
if "request" not in context:
return ""
request: HttpRequest = context["request"]
updated = request.GET.copy()
for key, value in kwargs.items():
updated[key] = value
return updated.urlencode()