{% extends 'layouts/layout_tcg.html' %}

{% block page_body %}
    <link rel="stylesheet" href="{{ url_for('static', filename='dist/css/user_accounts.bundle.css') }}">
    
    <form id="{{ model.ID_FORM_FILTERS }}" class="{{ model.FLAG_FILTER }} {{ model.FLAG_ROW }} {{ model.FLAG_CARD }}">
        {{ model.form_filters.hidden_tag() }}
        <div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_COLUMN }}">
            <div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}">
                <div class="{{ model.FLAG_CONTAINER_INPUT }} {{ model.FLAG_COLUMN }} {{ model.FLAG_FILTER }} {{ model.FLAG_SEARCH }}">
                    {{ model.form_filters.search.label }}
                    {{ model.form_filters.search() }}
                    {% for error in model.form_filters.search.errors %}
                        <p class="error">{{ error }}</p>
                    {% endfor %}
                </div>
                <div class="{{ model.FLAG_CONTAINER_INPUT }} {{ model.FLAG_COLUMN }} {{ model.FLAG_FILTER }} {{ model.FLAG_ACTIVE_ONLY }}" {{ model.ATTR_VALUE_PREVIOUS }}="{{ model.form_filters.active_only.data }}">
                    {{ model.form_filters.active_only.label }}
                    {{ model.form_filters.active_only() }}
                    {% for error in model.form_filters.active_only.errors %}
                        <p class="error">{{ error }}</p>
                    {% endfor %}
                    {% set class_name = model.FLAG_FILTER + ' ' + model.FLAG_ACTIVE_ONLY + ' ' + model.FLAG_CHECKBOX %}
                    {% include 'components/common/buttons/_icon_checkbox.html' %}
                </div>
            </div>
        </div>
        {% set block_id = 'buttons_table_default' %}
        {% include 'components/common/buttons/_buttons_save_cancel.html' %}
    </form>

    <table id="{{ model.ID_TABLE_MAIN }}" class="{{ model.FLAG_TABLE_MAIN }} {{ model.FLAG_ROW }} {{ model.FLAG_CARD }} {{ model.FLAG_USER }}">
        <thead>
            <tr class="{{ model.FLAG_USER }}">
                <th class="{{ model.FLAG_FIRSTNAME }}">First Name</th>
                <th class="{{ model.FLAG_SURNAME }}">Surname</th>
                <th class="{{ model.FLAG_NOTES }}">Notes</th>
                <th class="{{ model.FLAG_ACTIVE }}">
                    {% set class_name = model.FLAG_ACTIVE %}
                    {% set attribute_text = '' %}
                    {% include 'components/common/buttons/_icon_add.html' %}
                </th>
            </tr>
        </thead>
        <tbody>
            {% set is_blank_row = False %}
            {% for user in model.users %}
                {% include 'components/user/_row_user.html' %}
            {% endfor %}

            {% set is_blank_row = True %}
            {% include 'components/user/_row_user.html' %}
        </tbody>
    </table>
    
    {% include 'components/common/temporary/_overlay_confirm.html' %}
    {% include 'components/common/temporary/_overlay_error.html' %}

    <div id="{{ model.ID_CONTAINER_TEMPLATE_ELEMENTS }}">
        <!-- Active column -->
        <!-- Delete -->
        {% set class_name = '' %}
        {% include 'components/common/buttons/_icon_trash.html' %}
        <!-- Undelete -->
        {% set class_name = model.FLAG_ACTIVE %}
        {% set attribute_text = '' %}
        {% include 'components/common/buttons/_icon_add.html' %}
    </div>

    <script>
        var flagCanAdminUser = "{{ model.FLAG_CAN_ADMIN_USER }}";
        var flagIsEmailVerified = "{{ model.FLAG_IS_EMAIL_VERIFIED }}";
        var flagIsSuperUser = "{{ model.FLAG_IS_SUPER_USER }}";
        var users = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.users) | tojson | safe }};
    </script>
{% endblock %}