{#
/**
 * 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 class="ui basic fitted segment">
        <a
            href="{{ url_for('addDynamicField', {'form_name': form_name}) }}"
            class="ui labeled icon button addfield"
        >
            <i class="plus green icon" aria-hidden="true"></i>
            {{ _T("Add") }}
        </a>
    </div>
    <div class="ui basic fitted segment loader_selector">
        <table class="listing ui celled striped table">
            <thead>
                <tr>
                    <th class="id_row">#</th>
                    <th>{{ _T("Name") }}</th>
                    <th>{{ _T("Permissions") }}</th>
                    <th class="date_row">{{ _T("Type") }}</th>
                    <th class="date_row">{{ _T("Required") }}</th>
{% if preferences.pref_member_form_grid != 'one' %}
                    <th class="date_row">{{ _T("Width in forms") }}</th>
{% endif %}
                    <th>{{ _T("Actions") }}</th>
                </tr>
            </thead>
            <tbody>
{% for field in fields_list %}
                <tr>
                    <td data-scope="id" class="collapsing">{{ field.getIndex() }}</td>
                    <td class="left" data-scope="row">{{ field.getName()|escape }}</td>
                    <td class="left" data-col-label="{{ _T("Permissions") }}">{{ field.getPermissionName() }}</td>
                    <td class="left" data-col-label="{{ _T("Type") }}">{{ field.getTypeName() }}</td>
                    <td data-col-label="{{ _T("Required") }}">
    {% if field.getType != 0 %}
        {% if field.isRequired() %}{{ _T("Yes") }}{% else %}{{ _T("No") }}{% endif %}
    {% endif %}
                    </td>
    {% if preferences.pref_member_form_grid != 'one' %}
                    <td class="left" data-col-label="{{ _T("Width in forms") }}">
        {% if preferences.pref_member_form_grid == 'three' and field.getWidthInForms() == 3  %}
                        {{ _T("Half") }}
        {% elseif field.getWidthInForms() == 2 %}
                        {{ _T("Full") }}
        {% else %}
                        {{ _T("Default") }}
        {% endif %}
                    </td>
    {% endif %}
                    <td class="center actions_row">
                        <a
                            href="{{ url_for('editDynamicField', {'form_name': form_name, 'id': field.getId()}) }}"
                            class="action single-edit"
                        >
                            <i class="ui user edit blue icon tooltip" aria-hidden="true"></i>
                            <span class="ui special popup">{{ _T("Edit '%s' field")|replace({'%s': field.getName()}) }}</span>
                        </a>
                        <a
                            href="{{ url_for('dynamicTranslations', {'text_orig': field.getName(false)}) }}"
                            class="action single-translate"
                        >
                            <i class="ui language grey icon tooltip" aria-hidden="true"></i>
                            <span class="ui special popup">{{ _T("Translate '%s' field")|replace({'%s': field.getName()}) }}</span>
                        </a>
                        <a
                            href="{{ url_for('removeDynamicField', {'form_name': form_name, 'id': field.getId()}) }}"
                            class="delete"
                        >
                            <i class="ui trash red icon tooltip" aria-hidden="true"></i>
                            <span class="ui special popup">{{ _T("Delete '%s' field")|replace({'%s': field.getName()}) }}</span>
                        </a>
    {% if field.getIndex() == 1 %}
                        <i class="ui icon">&nbsp;</i>
    {% else %}
                        <a
                            href="{{ url_for('moveDynamicField', {'form_name': form_name, 'direction': 'up', 'id': field.getId()}) }}"
                        >
                            <i class="ui caret up grey icon tooltip" aria-hidden="true"></i>
                            <span class="ui special popup">{{ _T("Move up '%s' field")|replace({'%s': field.getName()}) }}</span>
                        </a>
    {% endif %}
    {% if field.getIndex() == fields_list|length %}
                        <i class="ui icon">&nbsp;</i>
    {% else %}
                        <a
                            href="{{ url_for('moveDynamicField', {'form_name': form_name, 'direction': 'down', 'id': field.getId()}) }}"
                        >
                            <i class="ui caret down grey icon tooltip" aria-hidden="true"></i>
                            <span class="ui special popup">{{ _T("Move down '%s' field")|replace({'%s': field.getName()}) }}</span>
                        </a>
    {% endif %}
                    </td>
                </tr>
{% else %}
                <tr>
                    <td colspan="7">
                        {{ _T("There is not yet any dynamic field configured for '%formname'")|replace({'%formname': form_title}) }}
                    </td>
                </tr>
{% endfor %}
            </tbody>
        </table>
    </div>
    <script type="text/javascript">
        {% include "elements/js/removal.js.twig" with {
            single_action: "true"
        } %}
    </script>
