mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Refactor HTMX table template
This commit is contained in:
@ -96,10 +96,7 @@
|
|||||||
{# Object table #}
|
{# Object table #}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body" id="object_list">
|
<div class="card-body" id="object_list">
|
||||||
<div class="table-responsive">
|
{% include 'htmx/table.html' %}
|
||||||
{% render_table table 'inc/table_htmx.html' %}
|
|
||||||
</div>
|
|
||||||
{% include 'inc/paginator_htmx.html' with paginator=table.paginator page=table.page %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{# Render an HTML table element #}
|
{# Render an HTMX-enabled table with paginator #}
|
||||||
{% load render_table from django_tables2 %}
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
{% render_table table 'inc/table_htmx.html' %}
|
{% render_table table 'inc/table_htmx.html' %}
|
||||||
|
@ -1,47 +1,49 @@
|
|||||||
{% load django_tables2 %}
|
{% load django_tables2 %}
|
||||||
|
|
||||||
<table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
|
<div class="table-responsive">
|
||||||
{% if table.show_header %}
|
<table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
|
||||||
<thead>
|
{% if table.show_header %}
|
||||||
<tr>
|
<thead>
|
||||||
{% for column in table.columns %}
|
|
||||||
{% if column.orderable %}
|
|
||||||
<th {{ column.attrs.th.as_html }}>
|
|
||||||
<a href="#"
|
|
||||||
hx-get="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}"
|
|
||||||
hx-target="#object_list"
|
|
||||||
hx-push-url="true"
|
|
||||||
>{{ column.header }}</a>
|
|
||||||
</th>
|
|
||||||
{% else %}
|
|
||||||
<th {{ column.attrs.th.as_html }}>{{ column.header }}</th>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
{% endif %}
|
|
||||||
<tbody>
|
|
||||||
{% for row in table.page.object_list|default:table.rows %}
|
|
||||||
<tr {{ row.attrs.as_html }}>
|
|
||||||
{% for column, cell in row.items %}
|
|
||||||
<td {{ column.attrs.td.as_html }}>{{ cell }}</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
{% empty %}
|
|
||||||
{% if table.empty_text %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="{{ table.columns|length }}" class="text-center text-muted">— {{ table.empty_text }} —</td>
|
{% for column in table.columns %}
|
||||||
|
{% if column.orderable %}
|
||||||
|
<th {{ column.attrs.th.as_html }}>
|
||||||
|
<a href="#"
|
||||||
|
hx-get="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}"
|
||||||
|
hx-target="#object_list"
|
||||||
|
hx-push-url="true"
|
||||||
|
>{{ column.header }}</a>
|
||||||
|
</th>
|
||||||
|
{% else %}
|
||||||
|
<th {{ column.attrs.th.as_html }}>{{ column.header }}</th>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
</thead>
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
</tbody>
|
<tbody>
|
||||||
{% if table.has_footer %}
|
{% for row in table.page.object_list|default:table.rows %}
|
||||||
<tfoot>
|
<tr {{ row.attrs.as_html }}>
|
||||||
<tr>
|
{% for column, cell in row.items %}
|
||||||
{% for column in table.columns %}
|
<td {{ column.attrs.td.as_html }}>{{ cell }}</td>
|
||||||
<td>{{ column.footer }}</td>
|
{% endfor %}
|
||||||
{% endfor %}
|
</tr>
|
||||||
</tr>
|
{% empty %}
|
||||||
</tfoot>
|
{% if table.empty_text %}
|
||||||
{% endif %}
|
<tr>
|
||||||
</table>
|
<td colspan="{{ table.columns|length }}" class="text-center text-muted">— {{ table.empty_text }} —</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
{% if table.has_footer %}
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
{% for column in table.columns %}
|
||||||
|
<td>{{ column.footer }}</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
{% endif %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
Reference in New Issue
Block a user