vendor/easycorp/easyadmin-bundle/src/Resources/views/crud/index.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. <table class="table datagrid {{ entities is empty ? 'datagrid-empty' }}">
  62. {% if num_results > 0 %}
  63. <thead>
  64. {% block table_head %}
  65. <tr>
  66. {% if has_batch_actions %}
  67. <th>
  68. <div class="form-check">
  69. <span><input type="checkbox" class="form-check-input form-batch-checkbox-all"></span>
  70. </div>
  71. </th>
  72. {% endif %}
  73. {% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %}
  74. {% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %}
  75. {% for field in entities|first.fields ?? [] %}
  76. {% set is_sorting_field = ea.search.isSortingField(field.property) %}
  77. {% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %}
  78. {% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}
  79. <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 }}">
  80. {% if field.isSortable %}
  81. <a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}">
  82. {{ field.label|raw }} <i class="fa fa-fw {{ column_icon }}"></i>
  83. </a>
  84. {% else %}
  85. <span>{{ field.label|raw }}</span>
  86. {% endif %}
  87. </th>
  88. {% endfor %}
  89. <th {% if ea.crud.showEntityActionsAsDropdown %}width="10px"{% endif %} dir="{{ ea.i18n.textDirection }}">
  90. <span class="sr-only">{{ 'action.entity_actions'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}</span>
  91. </th>
  92. </tr>
  93. {% endblock table_head %}
  94. </thead>
  95. {% endif %}
  96. <tbody>
  97. {% block table_body %}
  98. {% for entity in entities %}
  99. {% if not entity.isAccessible %}
  100. {% set some_results_are_hidden = true %}
  101. {% else %}
  102. <tr data-id="{{ entity.primaryKeyValueAsString }}">
  103. {% if has_batch_actions %}
  104. <td class="batch-actions-selector">
  105. <div class="form-check">
  106. <input type="checkbox" class="form-check-input form-batch-checkbox" value="{{ entity.primaryKeyValue }}">
  107. </div>
  108. </td>
  109. {% endif %}
  110. {% for field in entity.fields %}
  111. <td data-label="{{ field.label|e('html_attr') }}" class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" dir="{{ ea.i18n.textDirection }}">
  112. {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  113. </td>
  114. {% endfor %}
  115. {% block entity_actions %}
  116. <td class="actions {{ ea.crud.showEntityActionsAsDropdown ? 'actions-as-dropdown' }}">
  117. {% if entity.actions.count > 0 %}
  118. {% if ea.crud.showEntityActionsAsDropdown %}
  119. <div class="dropdown dropdown-actions">
  120. <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  121. {# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
  122. {# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
  123. <svg xmlns="http://www.w3.org/2000/svg" height="21" width="21" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  124. <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. {{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
  136. {% endfor %}
  137. {% endif %}
  138. {% endif %}
  139. </td>
  140. {% endblock entity_actions %}
  141. </tr>
  142. {% endif %}
  143. {% else %}
  144. {% block table_body_empty %}
  145. {% for i in 1..14 %}
  146. <tr class="empty-row">
  147. <td><span></span></td>
  148. <td><span></span></td>
  149. <td><span></span></td>
  150. <td><span></span></td>
  151. <td><span></span></td>
  152. <td><span></span></td>
  153. </tr>
  154. {% if 3 == loop.index %}
  155. <tr class="no-results">
  156. <td colspan="100">
  157. {{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}
  158. </td>
  159. </tr>
  160. {% endif %}
  161. {% endfor %}
  162. {% endblock table_body_empty %}
  163. {% endfor %}
  164. {% if some_results_are_hidden %}
  165. <tr class="datagrid-row-empty">
  166. <td class="text-center" colspan="{{ entities|first.fields|length + 1 }}">
  167. <span class="datagrid-row-empty-message"><i class="fa fa-lock mr-1"></i> {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
  168. </td>
  169. </tr>
  170. {% endif %}
  171. {% endblock table_body %}
  172. </tbody>
  173. <tfoot>
  174. {% block table_footer %}
  175. {% endblock table_footer %}
  176. </tfoot>
  177. </table>
  178. {% if entities|length > 0 %}
  179. <div class="content-panel-footer without-padding without-border">
  180. {% block paginator %}
  181. {{ include(ea.templatePath('crud/paginator'), { render_detailed_pagination: not some_results_are_hidden }) }}
  182. {% endblock paginator %}
  183. </div>
  184. {% endif %}
  185. {% block delete_form %}
  186. {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', with_context = false) }}
  187. {% endblock delete_form %}
  188. {% if has_filters %}
  189. {{ include('@EasyAdmin/crud/includes/_filters_modal.html.twig') }}
  190. {% endif %}
  191. {% if has_batch_actions %}
  192. {{ include('@EasyAdmin/crud/includes/_batch_action_modal.html.twig', {}, with_context = false) }}
  193. {% endif %}
  194. {% endblock main %}