You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
6.7KB

  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 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %}
  8. {% block content_title %}
  9. {{ 'sort'|sov_trans_admin_title(ea.getEntity().getFqcn()) }}
  10. {% endblock %}
  11. {% block content_breadcrumb %}
  12. {{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }}
  13. {% endblock content_breadcrumb %}
  14. {% set has_batch_actions = batch_actions|length > 0 %}
  15. {% block page_actions %}{% endblock page_actions %}
  16. {% block main %}
  17. {# sort can be multiple; let's consider the sorting field the first one #}
  18. {% set sort_field_name = app.request.get('sort')|keys|first %}
  19. {% set sort_order = app.request.get('sort')|first %}
  20. {% set some_results_are_hidden = false %}
  21. {% set has_footer = entities|length != 0 %}
  22. {% set has_search = ea.crud.isSearchEnabled %}
  23. {% set has_filters = filters|length > 0 %}
  24. {% set has_datagrid_tools = has_search or has_filters %}
  25. {{ form_start(sortable_form) }}
  26. {% embed '@LcSov/adminlte/embed/card.html.twig' %}
  27. {% block class %}card-table card-outline card-primary{% endblock %}
  28. {% block header %}
  29. <span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total">
  30. {{ paginator.numResults }} résultats
  31. </span>
  32. <div class="btn-list float-sm-right">
  33. <a href=" {{ ea_url({crudAction: 'index'}).generateUrl() }}" class="btn btn-sm btn-info">
  34. <i class="fa fa-chevron-left"></i>
  35. Retour à la liste
  36. </a>
  37. </div>
  38. {% endblock %}
  39. {% block body %}
  40. <div class="table-responsive">
  41. <table class="table table-bordered table-hover table-striped sov-sortable">
  42. {# data-parent-position="{{ ea.entity is defined and ea.entity.instance is not null ? ea.entity.instance.position : '' }}" #}
  43. <thead>
  44. {% block table_head %}
  45. <tr>
  46. <th></th>
  47. {% for field in fields ?? [] %}
  48. {% set field = field.getAsDto() %}
  49. {% if field.isDisplayedOn('index') %}
  50. {% set is_sorting_field = ea.search.isSortingField(field.property) %}
  51. <th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}"
  52. dir="{{ ea.i18n.textDirection }}">
  53. <span>
  54. {% if field.label is not null %}
  55. {{ field.label|raw }}
  56. {% else %}
  57. {{ field.getProperty|sov_trans_admin_field_index(translation_entity_name) }}
  58. {% endif %}
  59. </span>
  60. </th>
  61. {% endif %}
  62. {% endfor %}
  63. </tr>
  64. {% endblock table_head %}
  65. </thead>
  66. <tbody>
  67. {% block table_body %}
  68. {% for entity in entities %}
  69. {% if not entity.isAccessible %}
  70. {% set some_results_are_hidden = true %}
  71. {% else %}
  72. <tr class="sov-draggable" data-id="{{ entity.primaryKeyValueAsString }}">
  73. <td>
  74. <i class="fa fa-fw fa-sort"></i>
  75. </td>
  76. {% for field in entity.fields %}
  77. {% if field.isDisplayedOn('index') %}
  78. <td class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}"
  79. dir="{{ ea.i18n.textDirection }}">
  80. {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  81. </td>
  82. {% endif %}
  83. {% endfor %}
  84. </tr>
  85. {% endif %}
  86. {% else %}
  87. <tr>
  88. <td class="no-results" colspan="100">
  89. {{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}
  90. </td>
  91. </tr>
  92. {% endfor %}
  93. {% if some_results_are_hidden %}
  94. <tr class="datagrid-row-empty">
  95. <td class="text-center" colspan="{{ entities|first.fields|length + 1 }}">
  96. <span class="datagrid-row-empty-message"><i
  97. class="fa fa-lock mr-1"></i> {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
  98. </td>
  99. </tr>
  100. {% endif %}
  101. {% endblock table_body %}
  102. </tbody>
  103. </table>
  104. <div style="display: none;">
  105. {{ form_row(sortable_form.entities) }}
  106. {{ form_rest(sortable_form) }}
  107. </div>
  108. </div>
  109. {% endblock %}
  110. {% block footer %}
  111. <div class="form-actions">
  112. <div class="button-action">
  113. {# <a class=" {{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}" target="{{ _action.target }}">
  114. {{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
  115. </a> #}
  116. <button type="submit" class="btn btn-primary float-right"> Sauvegarder</button>
  117. </div>
  118. </div>
  119. {% endblock %}
  120. {% endembed %}
  121. {{ form_end(sortable_form) }}
  122. {% endblock main %}