{#
/**
 * Copyright © 2003-2024 The Galette Team
 *
 * This file is part of Galette (https://galette.eu).
 *
 * Galette is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Galette is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
 */
#}
{% extends 'elements/list.html.twig' %}

{% block infoline %}
    {% set infoline = {
        'label': _Tn("%count search", "%count searches", nb)|replace({"%count": nb}),
    } %}
    {{ parent() }}
{% endblock %}

{% block header %}
    {% set columns = [
        {'label': '#'},
        {'label': _T("Creation date")},
        {'label': _T("Name")},
        {'label': _T("Parameters")}
    ] %}
    {{ parent() }}
{% endblock %}

{% block body %}
    {% for search in searches %}
        <tr class="{% if loop.index % 2 == 0 %}even{% else %}odd{% endif %}">
            <td data-scope="row">
                {% if preferences.pref_show_id %}
                    {{ search.id }}
                {% else %}
                    {{ loop.index1 }}
                {% endif %}
            </td>
            <td class="left" data-col-label="{{ _T("Creation date") }}">{{ search.creation_date }}</td>
            <td class="left" data-col-label="{{ _T("Name") }}">{{ search.name|default("-") }}</td>
            <td class="left" data-col-label="{{ _T("Search parameters") }}">
                <details class="ui basic styled accordion">
                    <summary class="title">
                        <i class="info circle primary icon" aria-hidden="true"></i> {{ _T("Show parameters") }}
                    </summary>
                    <div class="content">
        {% for key, parameter in search.sparameters %}
                        <strong>{{ key }}:</strong> {{ parameter }}{% if not loop.last %}<br />{% endif %}
        {% endfor %}
                    </div>
                </details>
            </td>
            <td class="center actions_row">
                <a
                        href="{{ url_for("loadSearch", {"id": search.id}) }}"
                >
                    <i class="ui search icon tooltip" aria-hidden="true"></i>
                    <span class="ui special popup">{{ _T("Load saved search") }}</span>
                </a>

                <a
                        href="{{ url_for("removeSearch", {"id": search.id}) }}"
                        class="delete"
                >
                    <i class="ui trash red icon tooltip" aria-hidden="true"></i>
                    <span class="ui special popup">{{ _T("Remove saved search") }}</span>
                </a>
            </td>
        </tr>
    {% else %}
        <tr><td colspan="5" class="emptylist">{{ _T("no search") }}</td></tr>
    {% endfor %}
{% endblock %}

{% block javascripts %}
        <script type="text/javascript">
            $(function() {
                {% include "elements/js/removal.js.twig" with {
                    single_action: "true"
                } %}
            });
        </script>
{% endblock %}
