{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}

{% block admin_content %}
    {% embed '@ChillMain/CRUD/_index.html.twig' %}

        {% block table_entities %}
            <div class="flex-table">
                {% for entity in entities %}
                    <div class="item-bloc">
                        <div class="item-row">
                            <div class="wrap-header">
                                <div class="wh-row">
                                    <div class="wh-col">
                                        {{ entity|chill_entity_render_box }}
                                    </div>
                                    <div class="wh-col">
                                        {%- if not entity.active -%}
                                            <div>
                                                <span class="badge bg-danger">{{ 'user_group.inactive'|trans }}</span>
                                            </div>&nbsp;
                                        {%- endif -%}
                                        <div>{{ 'user_group.with_count_users'|trans({'count': entity.users|length}) }}</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="item-row separator">
                            <div class="wrap-list">
                                <div class="wl-row">
                                    <div class="wl-col title">
                                        <strong>{{ 'user_group.with_users'|trans }}</strong>
                                    </div>
                                    <div class="wl-col list">
                                        {% for user in entity.userListByLabelAscending %}
                                            <p class="wl-item">
                                            <span class="badge-user">
                                                {{ user|chill_entity_render_box }}
                                            </span>
                                            </p>
                                        {% else %}
                                            <p class="wl-item chill-no-data-statement">{{ 'user_group.no_users'|trans }}</p>
                                        {% endfor %}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="item-row separator">
                            <div class="wrap-list">
                                <div class="wl-row">
                                    <div class="wl-col title">
                                        <strong>{{ 'user_group.adminUsers'|trans }}</strong>
                                    </div>
                                    <div class="wl-col list">
                                        {% for user in entity.adminUserListByLabelAscending %}
                                            <p class="wl-item">
                                            <span class="badge-user">
                                                {{ user|chill_entity_render_box }}
                                            </span>
                                            </p>
                                        {% else %}
                                            <p class="wl-item chill-no-data-statement">{{ 'user_group.no_admin_users'|trans }}</p>
                                        {% endfor %}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="item-row separator">
                            <ul class="record_actions slim">
                                <li>
                                    <a href="{{ chill_path_add_return_path('chill_crud_admin_user_group_edit', {'id': entity.id}) }}" class="btn btn-edit"></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                {% endfor %}
            </div>
        {% endblock %}

        {% block actions_before %}
            <li class='cancel'>
                <a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans }}</a>
            </li>
        {% endblock %}

    {% endembed %}
{% endblock %}
