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 # Hide selection checkboxes
if 'pk' in table.base_columns: if 'pk' in table.base_columns:
table.columns.hide('pk') 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', { return render(request, 'htmx/table.html', {
'table': table, 'table': table,
'filter_chits': filter_chits, 'filter_form': filterset_form,
'model': model, 'model': model,
'actions': actions, '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"> <div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
{# Applied filters #} {# Applied filters #}
{% include 'inc/applied_filters_pane.html' %} {% applied_filters model form_filter request.GET %}
{# Object table controls #} {# Object table controls #}
{% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %} {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %}

View File

@ -4,7 +4,7 @@
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{# OOB Swaps to update various components #} {# OOB Swaps to update various components #}
{{ filter_chits }} {% applied_filters model form_filter request.GET %}
<div class="htmx-container table-responsive"> <div class="htmx-container table-responsive">
{% with preferences|get_key:"pagination.placement" as paginator_placement %} {% 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 %} {% load i18n %}
{% if applied_filters %} <div id="applied_filters_pane" hx-swap-oob="true">
<div class="mb-3"> {% if applied_filters %}
{% for filter in applied_filters %} <div class="mb-3">
<a href="{{ filter.link_url }}" class="badge rounded-pill text-bg-primary text-decoration-none me-1"> {% for filter in applied_filters %}
<i class="mdi mdi-close"></i> {{ filter.link_text }} <a href="{{ filter.link_url }}" class="badge rounded-pill text-bg-primary text-decoration-none me-1">
</a> <i class="mdi mdi-close"></i> {{ filter.link_text }}
{% endfor %} </a>
{% if applied_filters|length > 1 %} {% endfor %}
<a href="?" class="badge rounded-pill text-bg-danger text-decoration-none me-1"> {% if applied_filters|length > 1 %}
<i class="mdi mdi-tag-off"></i> {% trans "Clear all" %} <a href="?" class="badge rounded-pill text-bg-danger text-decoration-none me-1">
</a> <i class="mdi mdi-tag-off"></i> {% trans "Clear all" %}
{% endif %} </a>
{% if save_link %} {% endif %}
<a href="{{ save_link }}" class="badge rounded-pill text-bg-success text-decoration-none me-1"> {% if save_link %}
<i class="mdi mdi-content-save"></i> {% trans "Save" %} <a href="{{ save_link }}" class="badge rounded-pill text-bg-success text-decoration-none me-1">
</a> <i class="mdi mdi-content-save"></i> {% trans "Save" %}
{% endif %} </a>
</div> {% endif %}
{% endif %} </div>
{% endif %}
</div>

View File

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