Update display of filtering chits

This commit is contained in:
Daniel Sheppard 2025-01-20 12:02:02 -06:00
parent 852535e3d4
commit f2c74db761
6 changed files with 25 additions and 34 deletions

View File

@ -198,13 +198,9 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin):
# Hide selection checkboxes
if 'pk' in table.base_columns:
table.columns.hide('pk')
filter_chits = render_to_string('inc/applied_filters_pane.html', {
'model': model,
'filter_form': filterset_form,
}, request)
return render(request, 'htmx/table.html', {
'table': table,
'filter_chits': filter_chits,
'filter_form': filterset_form,
'model': model,
'actions': actions,
})

View File

@ -68,7 +68,7 @@ Context:
<div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
{# Applied filters #}
{% include 'inc/applied_filters_pane.html' %}
{% applied_filters model form_filter request.GET %}
{# Object table controls #}
{% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %}

View File

@ -4,7 +4,7 @@
{% load render_table from django_tables2 %}
{# OOB Swaps to update various components #}
{{ filter_chits }}
{% applied_filters model form_filter request.GET %}
<div class="htmx-container table-responsive">
{% with preferences|get_key:"pagination.placement" as paginator_placement %}

View File

@ -1,8 +0,0 @@
{% load helpers %}
<div id="applied_filters_pane" hx-swap-oob="true">
{# Applied filters #}
{% if filter_form %}
{% applied_filters model filter_form request.GET %}
{% endif %}
</div>

View File

@ -1,20 +1,22 @@
{% load i18n %}
{% if applied_filters %}
<div class="mb-3">
{% for filter in applied_filters %}
<a href="{{ filter.link_url }}" class="badge rounded-pill text-bg-primary text-decoration-none me-1">
<i class="mdi mdi-close"></i> {{ filter.link_text }}
</a>
{% endfor %}
{% if applied_filters|length > 1 %}
<a href="?" class="badge rounded-pill text-bg-danger text-decoration-none me-1">
<i class="mdi mdi-tag-off"></i> {% trans "Clear all" %}
</a>
{% endif %}
{% if save_link %}
<a href="{{ save_link }}" class="badge rounded-pill text-bg-success text-decoration-none me-1">
<i class="mdi mdi-content-save"></i> {% trans "Save" %}
</a>
{% endif %}
</div>
{% endif %}
<div id="applied_filters_pane" hx-swap-oob="true">
{% if applied_filters %}
<div class="mb-3">
{% for filter in applied_filters %}
<a href="{{ filter.link_url }}" class="badge rounded-pill text-bg-primary text-decoration-none me-1">
<i class="mdi mdi-close"></i> {{ filter.link_text }}
</a>
{% endfor %}
{% if applied_filters|length > 1 %}
<a href="?" class="badge rounded-pill text-bg-danger text-decoration-none me-1">
<i class="mdi mdi-tag-off"></i> {% trans "Clear all" %}
</a>
{% endif %}
{% if save_link %}
<a href="{{ save_link }}" class="badge rounded-pill text-bg-success text-decoration-none me-1">
<i class="mdi mdi-content-save"></i> {% trans "Save" %}
</a>
{% endif %}
</div>
{% endif %}
</div>

View File

@ -57,6 +57,7 @@ def widget_type(field):
# Inclusion tags
#
@register.inclusion_tag('form_helpers/render_fieldset.html')
def render_fieldset(form, fieldset):
"""