{#
/**
 * 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/>.
 */
#}
<div id="groups_field" class="field">
    <label>{{ _T("Groups:") }}</label>
    {% if login.isAdmin() or login.isStaff() or login.isGroupManager() %}
    <noscript><div class="ui message">{{ _T("This feature requires javascript.") }}</div></noscript>
    {% endif %}
    <span id="usergroups_form">
    {% if member.id %}
        {% for group in groups %}
            {% if member.isGroupMember(group.getName()) %}
            <input type="hidden" name="groups_adh[]" value="{{ group.getId() }}|{{ group.getName() }}"/>
            {% endif %}
        {% endfor %}
    {% endif %}
    </span>
    {% if login.isAdmin() or login.isStaff() or login.isGroupManager() %}
    <span id="managedgroups_form">
        {% if member.id %}
            {% for group in groups %}
                {% if member.isGroupManager(group.getName()) %}
                <input type="hidden" name="groups_managed_adh[]" value="{{ group.getId() }}|{{ group.getName() }}"/>
                {% endif %}
            {% endfor %}
        {% endif %}
    </span>
    {% endif %}
    {% if member.id %}
    <div class="ui large labels">
        {% for group in groups %}
            {% if member.isGroupMember(group.getName()) or member.isGroupManager(group.getName()) %}
                {% if member.isGroupMember(group.getName()) %}
                <span class="ui label member">
                    <i class="ui tag icon tooltip" title="{{ _T("Member of group") }}" aria-hidden="true"></i>
                {% endif %}
                {% if member.isGroupManager(group.getName()) %}
                <span class="ui label manager">
                    <i class="ui shield icon tooltip" title="{{ _T("Group manager") }}" aria-hidden="true"></i>
                {% endif %}
                    {{ group.getName() }}
                </span>
            {% endif %}
        {% endfor %}
    </div>
    {% endif %}
    {% if login.isGroupManager() %}
    <a class="jsonly disabled ui icon button" id="btngroups" tabindex="0">
        <i class="user tag icon" aria-hidden="true"></i>
        {{ _T("Manage user's groups") }}
    </a>
    {% endif %}
    {% if login.isAdmin() or login.isStaff() %}
    <a class="jsonly disabled ui icon button" id="btnmanagedgroups" tabindex="0">
        <i class="user shield icon" aria-hidden="true"></i>
        {{ _T("Manage user's managed groups") }}
    </a>
    {% endif %}
</div>
