templates/project/crud/indexv2.html.twig line 1

Open in your IDE?
  1. {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
  2. {# @var entities \EasyCorp\Bundle\EasyAdminBundle\Collection\EntityDtoCollection #}
  3. {# @var paginator \EasyCorp\Bundle\EasyAdminBundle\Orm\EntityPaginator #}
  4. {% extends ea.templatePath('layout') %}
  5. {% trans_default_domain ea.i18n.translationDomain %}
  6. {% block body_id entities|length > 0 ? 'ea-index-' ~ entities|first.name : '' %}
  7. {% block body_class 'ea-index' ~ (entities|length > 0 ? ' ea-index-' ~ entities|first.name : '') %}
  8. {% block content_title %}
  9.     {%- apply spaceless -%}
  10.         {% set custom_page_title = ea.crud.customPageTitle('index') %}
  11.         {{ custom_page_title is null
  12.             ? (ea.crud.defaultPageTitle('index')|trans(ea.i18n.translationParameters, 'EasyAdminBundle'))|raw
  13.             : (custom_page_title|trans(ea.i18n.translationParameters))|raw }}
  14.     {%- endapply -%}
  15. {% endblock %}
  16. {% set has_batch_actions = batch_actions|length > 0 %}
  17. {% block page_actions %}
  18.     {% if filters|length > 0 %}
  19.         <div class="datagrid-filters">
  20.             {% block filters %}
  21.                 {% set applied_filters = ea.request.query.all['filters']|default([])|keys %}
  22.                 <div class="btn-group action-filters">
  23.                     <a href="#" data-href="{{ ea_url().setAction('renderFilters').includeReferrer() }}" class="btn btn-secondary btn-labeled btn-labeled-right action-filters-button disabled {{ applied_filters ? 'action-filters-applied' }}" data-bs-toggle="modal" data-bs-target="#modal-filters">
  24.                         <i class="fa fa-filter fa-fw"></i> {{ 'filter.title'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}{% if applied_filters %} <span class="text-primary">({{ applied_filters|length }})</span>{% endif %}
  25.                     </a>
  26.                     {% if applied_filters %}
  27.                         <a href="{{ ea_url().unset('filters') }}" class="btn btn-secondary action-filters-reset">
  28.                             <i class="fa fa-close"></i>
  29.                         </a>
  30.                     {% endif %}
  31.                 </div>
  32.             {% endblock filters %}
  33.         </div>
  34.     {% endif %}
  35.     {% block global_actions %}
  36.         <div class="global-actions">
  37.             {% for action in global_actions %}
  38.                 {{ include(action.templatePath, { action: action }, with_context = false) }}
  39.             {% endfor %}
  40.         </div>
  41.     {% endblock global_actions %}
  42.     {% block batch_actions %}
  43.         {% if has_batch_actions %}
  44.             <div class="batch-actions" style="display: none">
  45.                 {% for action in batch_actions %}
  46.                     {{ include(action.templatePath, { action: action }, with_context = false) }}
  47.                 {% endfor %}
  48.             </div>
  49.         {% endif %}
  50.     {% endblock %}
  51. {% endblock page_actions %}
  52. {% block main %}
  53.     {# sort can be multiple; let's consider the sorting field the first one #}
  54.     {% set sort_field_name = app.request.get('sort')|keys|first %}
  55.     {% set sort_order = app.request.get('sort')|first %}
  56.     {% set some_results_are_hidden = false %}
  57.     {% set has_footer = entities|length != 0 %}
  58.     {% set has_search = ea.crud.isSearchEnabled %}
  59.     {% set has_filters = filters|length > 0 %}
  60.     {% set num_results = entities|length %}
  61.     {{ flasher_render() }}
  62.     <table class="table datagrid {{ entities is empty ? 'datagrid-empty' }}">
  63.         {% if num_results > 0 %}
  64.             <thead>
  65.             {% block table_head %}
  66.                 <tr>
  67.                     {% if has_batch_actions %}
  68.                         <th>
  69.                             <div class="form-check">
  70.                                 <span><input type="checkbox" class="form-check-input form-batch-checkbox-all"></span>
  71.                             </div>
  72.                         </th>
  73.                     {% endif %}
  74.                     {% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %}
  75.                     {% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %}
  76.                     {% for field in entities|first.fields ?? [] %}
  77.                         {% set is_sorting_field = ea.search.isSortingField(field.property) %}
  78.                         {% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %}
  79.                         {% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}
  80.                         <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 }}">
  81.                             {% if field.isSortable %}
  82.                                 <a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}">
  83.                                     {{ field.label|raw }} <i class="fa fa-fw {{ column_icon }}"></i>
  84.                                 </a>
  85.                             {% else %}
  86.                                 <span>{{ field.label|raw }}</span>
  87.                             {% endif %}
  88.                         </th>
  89.                     {% endfor %}
  90.                     <th {% if ea.crud.showEntityActionsAsDropdown %}width="10px"{% endif %} dir="{{ ea.i18n.textDirection }}">
  91.                         <span class="sr-only">{{ 'action.entity_actions'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}</span>
  92.                     </th>
  93.                 </tr>
  94.             {% endblock table_head %}
  95.             </thead>
  96.         {% endif %}
  97.         <tbody>
  98.         {% block table_body %}
  99.             {% for entity in entities %}
  100.                 {% if not entity.isAccessible %}
  101.                     {% set some_results_are_hidden = true %}
  102.                 {% else %}
  103.                     <tr data-id="{{ entity.primaryKeyValueAsString }}">
  104.                         {% if has_batch_actions %}
  105.                             <td class="batch-actions-selector">
  106.                                 <div class="form-check">
  107.                                     <input type="checkbox" class="form-check-input form-batch-checkbox" value="{{ entity.primaryKeyValue }}">
  108.                                 </div>
  109.                             </td>
  110.                         {% endif %}
  111.                         {% for field in entity.fields %}
  112.                             <td data-label="{{ field.label|e('html_attr') }}" class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" dir="{{ ea.i18n.textDirection }}">
  113.                                 {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  114.                             </td>
  115.                         {% endfor %}
  116.                         {% block entity_actions %}
  117.                             <td class="actions {{ ea.crud.showEntityActionsAsDropdown ? 'actions-as-dropdown' }}">
  118.                                 {% if entity.actions.count > 0 %}
  119.                                     {% if ea.crud.showEntityActionsAsDropdown %}
  120.                                         <div class="dropdown dropdown-actions">
  121.                                             <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  122.                                                 {# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
  123.                                                 {# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
  124.                                                     <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"/>
  125.                                                 </svg>
  126.                                             </a>
  127.                                             <div class="dropdown-menu dropdown-menu-right">
  128.                                                 {% for action in entity.actions %}
  129.                                                     {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  130.                                                 {% endfor %}
  131.                                             </div>
  132.                                         </div>
  133.                                     {% else %}
  134.                                         {% for action in entity.actions %}
  135.                                             {% if action.label == 'Supprimer' %}
  136.                                                 <div class="dropdown dropdown-actions d-flex float-end ms-2">
  137.                                                     <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  138.                                                         {# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
  139.                                                         {# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
  140.                                                             <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"/>
  141.                                                         </svg>
  142.                                                     </a>
  143.                                                     <div class="dropdown-menu dropdown-menu-right">
  144.                                                         {% for action in entity.actions %}
  145.                                                             {% if action.label == 'Supprimer' %}
  146.                                                                 {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  147.                                                             {% endif %}
  148.                                                         {% endfor %}
  149.                                                     </div>
  150.                                                 </div>
  151.                                             {% else %}
  152.                                                 {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  153.                                             {% endif %}
  154.                                         {% endfor %}
  155.                                     {% endif %}
  156.                                 {% endif %}
  157.                             </td>
  158.                         {% endblock entity_actions %}
  159.                     </tr>
  160.                 {% endif %}
  161.             {% else %}
  162.                 {% block table_body_empty %}
  163.                     {% for i in 1..14 %}
  164.                         <tr class="empty-row">
  165.                             <td><span></span></td>
  166.                             <td><span></span></td>
  167.                             <td><span></span></td>
  168.                             <td><span></span></td>
  169.                             <td><span></span></td>
  170.                             <td><span></span></td>
  171.                         </tr>
  172.                         {% if 3 == loop.index %}
  173.                             <tr class="no-results">
  174.                                 <td colspan="100">
  175.                                     {{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}
  176.                                 </td>
  177.                             </tr>
  178.                         {% endif %}
  179.                     {% endfor %}
  180.                 {% endblock table_body_empty %}
  181.             {% endfor %}
  182.             {% if some_results_are_hidden %}
  183.                 <tr class="datagrid-row-empty">
  184.                     <td class="text-center" colspan="{{ entities|first.fields|length + 1 }}">
  185.                         <span class="datagrid-row-empty-message"><i class="fa fa-lock mr-1"></i> {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
  186.                     </td>
  187.                 </tr>
  188.             {% endif %}
  189.         {% endblock table_body %}
  190.         </tbody>
  191.         <tfoot>
  192.         {% block table_footer %}
  193.         {% endblock table_footer %}
  194.         </tfoot>
  195.     </table>
  196.     {% if entities|length > 0 %}
  197.         <div class="content-panel-footer without-padding without-border">
  198.             {% block paginator %}
  199.                 {{ include(ea.templatePath('crud/paginator'), { render_detailed_pagination: not some_results_are_hidden }) }}
  200.             {% endblock paginator %}
  201.         </div>
  202.     {% endif %}
  203.     {% block delete_form %}
  204.         {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', with_context = false) }}
  205.     {% endblock delete_form %}
  206.     {% if has_filters %}
  207.         {{ include('@EasyAdmin/crud/includes/_filters_modal.html.twig') }}
  208.     {% endif %}
  209.     {% if has_batch_actions %}
  210.         {{ include('@EasyAdmin/crud/includes/_batch_action_modal.html.twig', {}, with_context = false) }}
  211.     {% endif %}
  212. {% endblock main %}