Skip to content

Storing State of Collapsed Filters #32

@srkunze

Description

@srkunze

Thanks for this project. I recently integrated these filter types and found that they currently don't match the style of Django 2.4.1.

I overrode the template filter_numeric_range.html with the following source:

{% load i18n %}

{% with choices.0 as choice %}
<details open>
    <summary>{% blocktrans with filter_title=title %} By {{ filter_title }}{% endblocktrans %} </summary>
    <form method="get" class="admin-numeric-filter-wrapper">
        {% for k, v in choice.request.GET.items %}
            {% if not k == choice.parameter_name|add:'_from' and not k == choice.parameter_name|add:'_to' %}
                <input type="hidden" name="{{ k }}" value="{{ v }}">
            {% endif %}
        {% endfor %}

        <div class="admin-numeric-filter-wrapper-group">
            {{ choice.form.as_p }}
        </div><!-- /.filter-numeric-filter-wrapper-group -->

        <button type="submit" class="submit">{% trans 'Apply' %}</button>
    </form>
</details>
{% endwith %}

As you can see the "summary" and "details" elements are present. Mind the spaces before/after the summary text content.

Unfortunately, collapsing works but restoring after a reload not.

I think this would be a valuable addition to this plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions