{% set queryParameters = app.request.query.all %}
{% set baseParameters = app.request.attributes.get('_route_params')|merge(queryParameters) %}

{% set appliedAttributes = app.request.query.get('attribute') %}

{%- set appliedFilters -%}
    {%- for filter in resultSet.filters -%}
        {%- set currentValues = (appliedAttributes[filter.code] is defined) ? appliedAttributes[filter.code] : [] -%}

        {%- for value in currentValues -%}
            {%- set parameters = baseParameters|unset_nested_value(['attribute', filter.code], value) -%}

            <a href="{{ path(app.request.attributes.get('_route'), parameters, true) }}" class="btn btn-secondary">&times; {{ value }}</a>
        {%- endfor -%}
    {%- endfor -%}
{%- endset -%}

{% if appliedFilters != '' %}
    <li class="list-group-item">
        {{ appliedFilters }}

        <hr>
        {% set parameters = baseParameters|unset_nested_key(['attribute']) %}

        {# todo: ajouter une traduction pour la clé Réinitialisation dans le dedi-theme #}
        <a href="{{ path(app.request.attributes.get('_route'), parameters, true) }}" class="btn btn-secondary">&times; {{ 'monsieurbiz_searchplugin.filters.reinit_btn'|trans }}</a>
    </li>
{% endif %}
