Hide paginator for empty pages

This commit is contained in:
Jeremy Stretch 2024-01-05 15:51:18 -05:00
parent e30ff425a8
commit 8197e83d96
3 changed files with 120 additions and 107 deletions

Binary file not shown.

View File

@ -1,3 +1,14 @@
// Object list tables
table.object-list {
// Hide border of last row
tbody > tr:last-child > td {
border-bottom-width: 0;
}
}
// Object attribute tables
table.attr-table { table.attr-table {
// Restyle row header // Restyle row header

View File

@ -1,115 +1,117 @@
{% load helpers %} {% load helpers %}
{% load i18n %} {% load i18n %}
<div class="d-flex justify-content-between align-items-center p-2"> {% if page %}
<div class="d-flex justify-content-between align-items-center border-top p-2">
{# Pages carousel #} {# Pages carousel #}
{% if paginator.num_pages > 1 %} {% if paginator.num_pages > 1 %}
<nav aria-label="{% trans "Page selection" %}"> <nav aria-label="{% trans "Page selection" %}">
<ul class="pagination mb-0"> <ul class="pagination mb-0">
{# Previous page #} {# Previous page #}
{% if page.has_previous %} {% if page.has_previous %}
<li class="page-item"> <li class="page-item">
{% if htmx %} {% if htmx %}
<a href="#" <a href="#"
hx-get="{{ table.htmx_url }}{% querystring request page=page.previous_page_number %}" hx-get="{{ table.htmx_url }}{% querystring request page=page.previous_page_number %}"
hx-target="closest .htmx-container" hx-target="closest .htmx-container"
{% if not table.embedded %}hx-push-url="true"{% endif %} {% if not table.embedded %}hx-push-url="true"{% endif %}
class="page-link" class="page-link"
> >
<i class="mdi mdi-chevron-left"></i> <i class="mdi mdi-chevron-left"></i>
</a> </a>
{% else %} {% else %}
<a href="{% querystring request page=page.previous_page_number %}" class="page-link"> <a href="{% querystring request page=page.previous_page_number %}" class="page-link">
<i class="mdi mdi-chevron-left"></i> <i class="mdi mdi-chevron-left"></i>
</a> </a>
{% endif %} {% endif %}
</li> </li>
{% endif %} {% endif %}
{# /Previous page #} {# /Previous page #}
{# Page numbers #} {# Page numbers #}
{% for p in page.smart_pages %} {% for p in page.smart_pages %}
<li class="page-item{% if page.number == p %} active" aria-current="page{% endif %}"> <li class="page-item{% if page.number == p %} active" aria-current="page{% endif %}">
{% if p and htmx %} {% if p and htmx %}
<a href="#" <a href="#"
hx-get="{{ table.htmx_url }}{% querystring request page=p %}" hx-get="{{ table.htmx_url }}{% querystring request page=p %}"
hx-target="closest .htmx-container" hx-target="closest .htmx-container"
{% if not table.embedded %}hx-push-url="true"{% endif %} {% if not table.embedded %}hx-push-url="true"{% endif %}
class="page-link" class="page-link"
> >
{{ p }} {{ p }}
</a> </a>
{% elif p %} {% elif p %}
<a href="{% querystring request page=p %}" class="btn btn-outline-secondary{% if page.number == p %} active{% endif %}"> <a href="{% querystring request page=p %}" class="btn btn-outline-secondary{% if page.number == p %} active{% endif %}">
{{ p }} {{ p }}
</a> </a>
{% else %} {% else %}
<span class="page-link" disabled>&hellip;</span> <span class="page-link" disabled>&hellip;</span>
{% endif %} {% endif %}
</li> </li>
{% endfor %}
{# /Page numbers #}
{# Next page #}
{% if page.has_next %}
<li class="page-item">
{% if htmx %}
<a href="#"
hx-get="{{ table.htmx_url }}{% querystring request page=page.next_page_number %}"
hx-target="closest .htmx-container"
{% if not table.embedded %}hx-push-url="true"{% endif %}
class="page-link"
>
<i class="mdi mdi-chevron-right"></i>
</a>
{% else %}
<a href="{% querystring request page=page.next_page_number %}" class="page-link">
<i class="mdi mdi-chevron-right"></i>
</a>
{% endif %}
</li>
{% endif %}
{# /Next page #}
</ul>
</nav>
{% endif %}
{# /Pages carousel #}
{# Showing #}
<small class="text-end text-muted">
{% blocktrans trimmed with start=page.start_index end=page.end_index total=page.paginator.count %}
Showing {{ start }}-{{ end }} of {{ total }}
{% endblocktrans %}
</small>
{# /Showing #}
{# Pagination options #}
<nav class="text-end" aria-label="{% trans "Pagination options" %}">
{% if page %}
<div class="dropdown">
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
{% trans "Per Page" %}
</button>
<div class="dropdown-menu">
{% for n in page.paginator.get_page_lengths %}
{% if htmx %}
<a href="#"
hx-get="{{ table.htmx_url }}{% querystring request per_page=n %}"
hx-target="closest .htmx-container"
{% if not table.embedded %}hx-push-url="true"{% endif %}
class="dropdown-item"
>{{ n }}</a>
{% else %}
<a href="{% querystring request per_page=n %}" class="dropdown-item">{{ n }}</a>
{% endif %}
{% endfor %} {% endfor %}
</div> {# /Page numbers #}
</div>
{% endif %}
</nav>
{# /Pagination options #}
</div> {# Next page #}
{% if page.has_next %}
<li class="page-item">
{% if htmx %}
<a href="#"
hx-get="{{ table.htmx_url }}{% querystring request page=page.next_page_number %}"
hx-target="closest .htmx-container"
{% if not table.embedded %}hx-push-url="true"{% endif %}
class="page-link"
>
<i class="mdi mdi-chevron-right"></i>
</a>
{% else %}
<a href="{% querystring request page=page.next_page_number %}" class="page-link">
<i class="mdi mdi-chevron-right"></i>
</a>
{% endif %}
</li>
{% endif %}
{# /Next page #}
</ul>
</nav>
{% endif %}
{# /Pages carousel #}
{# Showing #}
<small class="text-end text-muted">
{% blocktrans trimmed with start=page.start_index end=page.end_index total=page.paginator.count %}
Showing {{ start }}-{{ end }} of {{ total }}
{% endblocktrans %}
</small>
{# /Showing #}
{# Pagination options #}
<nav class="text-end" aria-label="{% trans "Pagination options" %}">
{% if page %}
<div class="dropdown">
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
{% trans "Per Page" %}
</button>
<div class="dropdown-menu">
{% for n in page.paginator.get_page_lengths %}
{% if htmx %}
<a href="#"
hx-get="{{ table.htmx_url }}{% querystring request per_page=n %}"
hx-target="closest .htmx-container"
{% if not table.embedded %}hx-push-url="true"{% endif %}
class="dropdown-item"
>{{ n }}</a>
{% else %}
<a href="{% querystring request per_page=n %}" class="dropdown-item">{{ n }}</a>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
</nav>
{# /Pagination options #}
</div>
{% endif %}