<table class="table datagrid {{ entities is empty ? 'datagrid-empty' }}">
{% if num_results > 0 %}
<thead>
{% block table_head %}
<tr>
{% if has_batch_actions %}
<th>
<div class="form-check">
<span><input type="checkbox" class="form-check-input form-batch-checkbox-all" hidden></span>
</div>
</th>
{% endif %}
{% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %}
{% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %}
{% for field in entities|first.fields ?? [] %}
{% set is_sorting_field = ea.search.isSortingField(field.property) %}
{% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %}
{% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}
{% if field.label != "Niveau" %}
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} header-for-{{ field.cssClass|split(' ')|filter(class => class starts with 'field-')|join('') }} text-{{ field.textAlign }}" dir="{{ ea.i18n.textDirection }}">
{% if field.isSortable %}
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}">
{{ field.label|raw }}
<i class="fa fa-fw {{ column_icon }}"></i>
</a>
{% else %}
<span>{{ field.label|raw }}</span>
{% endif %}
</th>
{% endif %}
{% endfor %}
<th {% if ea.crud.showEntityActionsAsDropdown %} width="10px" {% endif %} dir="{{ ea.i18n.textDirection }}">
<span class="sr-only">{{ 'action.entity_actions'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}</span>
</th>
</tr>
{% endblock table_head %}
</thead>
{% endif %}
<tbody>
{% block table_body %}
{% set parentLabel = '' %}
{% for entity in entities %}
{% set parentName = entity.instance.parent %}
{% if not entity.isAccessible %}
{% set some_results_are_hidden = true %}
{% else %}
{% if parentName != parentLabel %}
<tr>
<td colspan="3">
<p class="text-center">
<b>
{{parentName}}</b>
</p>
</td>
<td colspan="6"></td>
</tr>
{% set parentLabel = entity.instance.parent %}
{% endif %}
<tr data-id="{{ entity.primaryKeyValueAsString }}">
{% if has_batch_actions %}
<td class="batch-actions-selector">
<div class="form-check">
<input type="checkbox" class="form-check-input form-batch-checkbox" value="{{ entity.primaryKeyValue }}">
</div>
</td>
{% endif %}
{% for field in entity.fields %}
{% if field.label != "Niveau" %}
{% if field.label == "Parent" %}
<td></td>
{% else %}
<td data-label="{{ field.label|e('html_attr') }}" class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" dir="{{ ea.i18n.textDirection }}">
{{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
</td>
{% endif %}
{% endif %}
{% endfor %}
{% block entity_actions %}
<td class="actions {{ ea.crud.showEntityActionsAsDropdown ? 'actions-as-dropdown' }}">
{% if entity.actions.count > 0 %}
{% if ea.crud.showEntityActionsAsDropdown %}
<div class="dropdown dropdown-actions">
<a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
{# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
<svg xmlns="http://www.w3.org/2000/svg" height="21" width="21" fill="none" viewbox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z"/>
</svg>
</a>
<div class="dropdown-menu dropdown-menu-right">
{% for action in entity.actions %}
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
{% endfor %}
</div>
</div>
{% else %}
{% for action in entity.actions %}
{% if action.label == 'Supprimer' %}
<div class="dropdown dropdown-actions d-flex float-end ms-2">
<a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
{# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
<svg xmlns="http://www.w3.org/2000/svg" height="21" width="21" fill="none" viewbox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z"/>
</svg>
</a>
<div class="dropdown-menu dropdown-menu-right">
{% for action in entity.actions %}
{% if action.label == 'Supprimer' %}
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
{% endif %}
{% endfor %}
</div>
</div>
{% else %}
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
</td>
{% endblock entity_actions %}
</tr>
{% endif %}
{% else %}
{% block table_body_empty %}
{% for i in 1..14 %}
<tr class="empty-row">
<td>
<span></span>
</td>
<td>
<span></span>
</td>
<td>
<span></span>
</td>
<td>
<span></span>
</td>
<td>
<span></span>
</td>
<td>
<span></span>
</td>
</tr>
{% if 3 == loop.index %}
<tr class="no-results">
<td colspan="100">
{{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}
</td>
</tr>
{% endif %}
{% endfor %}
{% endblock table_body_empty %}
{% endfor %}
{% if some_results_are_hidden %}
<tr class="datagrid-row-empty">
<td class="text-center" colspan="{{ entities|first.fields|length + 1 }}">
<span class="datagrid-row-empty-message">
<i class="fa fa-lock mr-1"></i>
{{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
</td>
</tr>
{% endif %}
{% endblock table_body %}
</tbody>
<tfoot>
{% block table_footer %}{% endblock table_footer %}
</tfoot>
</table>
{% if entities|length > 0 %}
<div class="content-panel-footer without-padding without-border">
{% block paginator %}
{{ include(ea.templatePath('crud/paginator'), { render_detailed_pagination: not some_results_are_hidden }) }}
{% endblock paginator %}
</div>
{% endif %}