{#
/**
 * 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/>.
 */
#}
{% set is_public = not login.isLogged() %}
{% extends is_public ? "public_page.html.twig" : "page.html.twig" %}

{% macro getSlug(value) -%}
    {{ value|lower|spaceless|slug|e('html_attr') }}
{%- endmacro %}

{% block content %}
    {% if typed_documents|length == 0 %}
        <div class="ui small message">
            <div class="content">
                <em>{{ _T("No document") }}</em>
            </div>
        </div>
    {% else %}
        <div class="ui stackable grid">
            <div class="four wide column">
                <div class="ui vertical inverted pointing fluid menu tabbed">
        {% for type, documents in typed_documents %}
                    <a class="{% if loop.index == 1 %}active {% endif %}item" data-tab="{{ _self.getSlug(type) }}">
                        {{ _T(type) }}
                        <p class="ui small disabled text">({{ _Tn("%count document", "%count documents", documents|length)|replace({"%count": documents|length}) }})</p>
                    </a>
        {% endfor %}
                </div>
            </div>
            <div class="twelve wide column">
        {% for type, documents in typed_documents %}
                <div class="ui tab{% if loop.index == 1 %} active{% endif %}" data-tab="{{ _self.getSlug(type) }}">
                    <div class="ui segment">
                        <div class="ui divided relaxed list">
            {% for document in documents %}
                            <div class="item">
                                <div class="ui tiny image">
                                    <i class="large file middle aligned icon"></i>
                                </div>
                                <div class="content">
                                    <a class="ui small header" href="{{ url_for('getDocumentFile', {'id': document.getID()}) }}">
                                        {{ document.getDocumentFilename() }}
                                    </a>
                                    <div class="description">
                                        {% if document.getComment %}{{ document.getComment()|raw }}{% endif %}
                                    </div>
                                    <div class="extra">
                                        <div class="ui right floated meta">
                                            <span class="date ui small text">
                                                <i class="clock outline icon"></i>
                                                {{ document.getCreationDate() }}
                                            </span>
                                            <div class="ui label">{{ document.getPermissionName() }}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
            {% endfor %}
                        </div>
                    </div>
                </div>
        {% endfor %}
            </div>
        </div>
    {% endif %}
{% endblock %}
