templates/content/page/crud/index-code.html.twig line 1

Open in your IDE?
  1. <table class="table datagrid {{ entities is empty ? 'datagrid-empty' }}">
  2.     {% if num_results > 0 %}
  3.         <thead>
  4.             {% block table_head %}
  5.                 <tr>
  6.                     {% if has_batch_actions %}
  7.                         <th>
  8.                             <div class="form-check">
  9.                                 <span><input type="checkbox" class="form-check-input form-batch-checkbox-all" hidden></span>
  10.                             </div>
  11.                         </th>
  12.                     {% endif %}
  13.                     {% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %}
  14.                     {% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %}
  15.                     {% for field in entities|first.fields ?? [] %}
  16.                         {% set is_sorting_field = ea.search.isSortingField(field.property) %}
  17.                         {% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %}
  18.                         {% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}
  19.                         {% if field.label != "Niveau" %}
  20.                             <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 }}">
  21.                                 {% if field.isSortable %}
  22.                                     <a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}">
  23.                                         {{ field.label|raw }}
  24.                                         <i class="fa fa-fw {{ column_icon }}"></i>
  25.                                     </a>
  26.                                 {% else %}
  27.                                     <span>{{ field.label|raw }}</span>
  28.                                 {% endif %}
  29.                             </th>
  30.                         {% endif %}
  31.                     {% endfor %}
  32.                     <th {% if ea.crud.showEntityActionsAsDropdown %} width="10px" {% endif %} dir="{{ ea.i18n.textDirection }}">
  33.                         <span class="sr-only">{{ 'action.entity_actions'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}</span>
  34.                     </th>
  35.                 </tr>
  36.             {% endblock table_head %}
  37.         </thead>
  38.     {% endif %}
  39.     <tbody>
  40.         {% block table_body %}
  41.             {% set parentLabel = '' %}
  42.             {% for entity in entities %}
  43.                 {% set parentName = entity.instance.parent %}
  44.                 {% if not entity.isAccessible %}
  45.                     {% set some_results_are_hidden = true %}
  46.                 {% else %}
  47.                     {% if parentName != parentLabel %}
  48.                         <tr>
  49.                             <td colspan="3">
  50.                                 <p class="text-center">
  51.                                     <b>
  52.                                         {{parentName}}</b>
  53.                                 </p>
  54.                             </td>
  55.                             <td colspan="6"></td>
  56.                         </tr>
  57.                         {% set parentLabel = entity.instance.parent %}
  58.                     {% endif %}
  59.                     <tr data-id="{{ entity.primaryKeyValueAsString }}">
  60.                         {% if has_batch_actions %}
  61.                             <td class="batch-actions-selector">
  62.                                 <div class="form-check">
  63.                                     <input type="checkbox" class="form-check-input form-batch-checkbox" value="{{ entity.primaryKeyValue }}">
  64.                                 </div>
  65.                             </td>
  66.                         {% endif %}
  67.                         {% for field in entity.fields %}
  68.                             {% if field.label != "Niveau" %}
  69.                                 {% if field.label == "Parent" %}
  70.                                     <td></td>
  71.                                 {% else %}
  72.                                     <td data-label="{{ field.label|e('html_attr') }}" class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" dir="{{ ea.i18n.textDirection }}">
  73.                                         {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  74.                                     </td>
  75.                                 {% endif %}
  76.                             {% endif %}
  77.                         {% endfor %}
  78.                         {% block entity_actions %}
  79.                             <td class="actions {{ ea.crud.showEntityActionsAsDropdown ? 'actions-as-dropdown' }}">
  80.                                 {% if entity.actions.count > 0 %}
  81.                                     {% if ea.crud.showEntityActionsAsDropdown %}
  82.                                         <div class="dropdown dropdown-actions">
  83.                                             <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  84.                                                 {# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
  85.                                                 {# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
  86.                                                     <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"/>
  87.                                                 </svg>
  88.                                             </a>
  89.                                             <div class="dropdown-menu dropdown-menu-right">
  90.                                                 {% for action in entity.actions %}
  91.                                                     {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  92.                                                 {% endfor %}
  93.                                             </div>
  94.                                         </div>
  95.                                     {% else %}
  96.                                         {% for action in entity.actions %}
  97.                                             {% if action.label == 'Supprimer' %}
  98.                                                 <div class="dropdown dropdown-actions d-flex float-end ms-2">
  99.                                                     <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  100.                                                         {# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
  101.                                                         {# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
  102.                                                             <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"/>
  103.                                                         </svg>
  104.                                                     </a>
  105.                                                     <div class="dropdown-menu dropdown-menu-right">
  106.                                                         {% for action in entity.actions %}
  107.                                                             {% if action.label == 'Supprimer' %}
  108.                                                                 {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  109.                                                             {% endif %}
  110.                                                         {% endfor %}
  111.                                                     </div>
  112.                                                 </div>
  113.                                             {% else %}
  114.                                                 {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  115.                                             {% endif %}
  116.                                         {% endfor %}
  117.                                     {% endif %}
  118.                                 {% endif %}
  119.                             </td>
  120.                         {% endblock entity_actions %}
  121.                     </tr>
  122.                 {% endif %}
  123.             {% else %}
  124.                 {% block table_body_empty %}
  125.                     {% for i in 1..14 %}
  126.                         <tr class="empty-row">
  127.                             <td>
  128.                                 <span></span>
  129.                             </td>
  130.                             <td>
  131.                                 <span></span>
  132.                             </td>
  133.                             <td>
  134.                                 <span></span>
  135.                             </td>
  136.                             <td>
  137.                                 <span></span>
  138.                             </td>
  139.                             <td>
  140.                                 <span></span>
  141.                             </td>
  142.                             <td>
  143.                                 <span></span>
  144.                             </td>
  145.                         </tr>
  146.                         {% if 3 == loop.index %}
  147.                             <tr class="no-results">
  148.                                 <td colspan="100">
  149.                                     {{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}
  150.                                 </td>
  151.                             </tr>
  152.                         {% endif %}
  153.                     {% endfor %}
  154.                 {% endblock table_body_empty %}
  155.             {% endfor %}
  156.             {% if some_results_are_hidden %}
  157.                 <tr class="datagrid-row-empty">
  158.                     <td class="text-center" colspan="{{ entities|first.fields|length + 1 }}">
  159.                         <span class="datagrid-row-empty-message">
  160.                             <i class="fa fa-lock mr-1"></i>
  161.                             {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
  162.                     </td>
  163.                 </tr>
  164.             {% endif %}
  165.         {% endblock table_body %}
  166.     </tbody>
  167.     <tfoot>
  168.         {% block table_footer %}{% endblock table_footer %}
  169.     </tfoot>
  170. </table>
  171. {% if entities|length > 0 %}
  172.     <div class="content-panel-footer without-padding without-border">
  173.         {% block paginator %}
  174.             {{ include(ea.templatePath('crud/paginator'), { render_detailed_pagination: not some_results_are_hidden }) }}
  175.         {% endblock paginator %}
  176.     </div>
  177. {% endif %}