{#
/**
 * Copyright (C) 2020-2023 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - https://xibosignage.com
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}
{% set randomId = random() %}

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}
{% import "inline.twig" as inline %}

{% block formTitle %}
    {% set userName = user.userName %}
    {% trans %}Manage Membership for {{ userName }}{% endtrans %}
{% endblock %}

{% block formButtons %}
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, membersFormSubmit("{{ randomId }}")
{% endblock %}

{% block callBack %}membersFormOpen{% endblock %}

{% block extra %}{{ extra|json_encode|raw }}{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <div id="{{ randomId }}" class="div-horizontal controlDiv"
                 data-user-groups="true"
                 data-user-groups-get-url="{{ url_for("group.search") }}"
                 data-user-groups-param="userGroupId"
                 data-user-groups-param-unassign="unassignUserGroupId"
                 data-user-groups-url="{{ url_for("user.assign.userGroup", {id: user.userId}) }}"
            >
                {% set helpText %}{% trans %}Check or un-check the options against each display group to control whether they are a member or not.{% endtrans %}{% endset %}
                {{ forms.message(helpText) }}
                <div class="XiboGrid" id="{{ random() }}">
                    <div class="XiboFilter card mb-3 bg-light">
                        <div class="FilterDiv card-body" id="Filter">
                            <form class="form-inline" id="userGroupMembersFilter">
                                {% set title %}{% trans "Name" %}{% endset %}
                                {{ inline.input("group", title) }}
                                {{ inline.hidden("userIdMember", user.userId) }}
                            </form>
                        </div>
                    </div>
                    <table id="userGroupMembersTable" class="table table-bordered membersTable" style="width: 100%">
                        <thead>
                        <tr>
                            <th>{% trans "ID" %}</th>
                            <th>{% trans "User Groups" %}</th>
                            <th>{% trans "Member" %}</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
{% endblock %}