{#
 * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
 *
 * This program 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 (at your option) any later version.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
#}
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}

{% block title %}{{ 'CustomFieldsGroup list'|trans }}{% endblock %}

{% block admin_content %}
    <h1>{{ 'CustomFieldsGroup list'|trans }}</h1>

    <table class="records_list">
        <thead>
            <tr>
                <th>{{ 'Name'|trans }}</th>
                <th>{{ 'Entity'|trans }}</th>
                <th>{{ 'Is default ?'|trans }} <i class="fa fa-info-circle" title="{{ 'Some module select default groups for some usage. Example: the default person group is shown under person page.'|trans|escape('html_attr') }}"></i></th>
                <th>{{ 'Actions'|trans }}</th>
            </tr>
        </thead>
        <tbody>
        {% for entity in entities %}
            <tr>
                <td><a href="{{ path('customfieldsgroup_show', { 'id': entity.id }) }}">{{ entity.name|localize_translatable_string }}</a></td>
                <td>{{ entity.entity|trans }}</td>
                <td style="text-align: center;">
                    {%- if entity.id in default_groups -%}
                        <i class="fa fa-star"></i>
                    {%- else -%}
                        {{ form_start(make_default_forms[entity.id]) }}
                        {{ form_widget(make_default_forms[entity.id].submit, { 'attr' : { 'class' : 'btn btn-action' } } ) }}
                        {{ form_end(make_default_forms[entity.id]) }}
                    {%- endif -%}
                </td>
                <td>
                <ul class="record_actions">
                    <li>
                        <a href="{{ path('customfieldsgroup_show', { 'id': entity.id }) }}" class="btn btn-show">{{ 'show'|trans|capitalize }}</a>
                    </li>
                    <li>
                        <a href="{{ path('customfieldsgroup_edit', { 'id': entity.id }) }}" class="btn btn-edit">{{ 'edit'|trans|capitalize }}</a>
                    </li>
                </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    <p>
        <a href="{{ path('customfieldsgroup_new') }}" class="btn btn-create">
            {{ 'Create a new group'|trans }}
        </a>
    </p>
    {% endblock %}
