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.

242 lines
11KB

  1. {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
  2. {% use '@EasyAdmin/crud/form_theme.html.twig' %}
  3. {% block gallery_manager_row %}
  4. {{ block('collection_row') }}
  5. {% endblock gallery_manager_row %}
  6. {% block gallery_manager_widget %}
  7. {{ block('collection_widget') }}
  8. {% endblock gallery_manager_widget %}
  9. {% block collection_row %}
  10. {% if prototype is defined and not prototype.rendered %}
  11. {% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %}
  12. {% endif %}
  13. {% set row_attr = row_attr|merge({
  14. 'data-entry-is-complex': form.vars.ea_crud_form.ea_field and form.vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ? 'true' : 'false',
  15. 'data-allow-add': allow_add ? 'true' : 'false',
  16. 'data-allow-delete': allow_delete ? 'true' : 'false',
  17. 'data-num-items': form.children|length,
  18. 'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '',
  19. }) %}
  20. {{ block('form_row') }}
  21. {% endblock collection_row %}
  22. {% block collection_widget %}
  23. {{ block('form_widget') }}
  24. {% if allow_add|default(false) %}
  25. <button type="button" class="btn btn-link field-collection-add">
  26. <i class="fa fa-plus pr-1"></i>
  27. {{ 'action.add_new_item'|trans({}, 'EasyAdminBundle') }}
  28. </button>
  29. {% endif %}
  30. {% endblock collection_widget %}
  31. {% block collection_entry_widget %}
  32. {% set is_complex = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ?? false %}
  33. <div class="field-collection-item {{ is_complex ? 'field-collection-item-complex' }}">
  34. {{ form_widget(form) }}
  35. {% if form_parent(form).vars.allow_delete|default(false) %}
  36. <button type="button" class="btn btn-link field-collection-delete"
  37. title="{{ 'action.remove_item'|trans({}, 'EasyAdminBundle') }}">
  38. <i class="fas fa-times"></i>
  39. </button>
  40. {% endif %}
  41. </div>
  42. {% endblock collection_entry_widget %}
  43. {% block file_manager_image_row %}
  44. {{ form_widget(form) }}
  45. {% endblock file_manager_image_row %}
  46. {% block file_manager_legend_row %}
  47. {{ form_widget(form) }}
  48. {% endblock file_manager_legend_row %}
  49. {% block file_manager_position_row %}
  50. {{ form_widget(form) }}
  51. {% endblock file_manager_position_row %}
  52. {% block file_manager_widget %}
  53. <div class="lc-filemanager row">
  54. <div class="col-md-3 col-xs-12 form-group">
  55. <div class="lc-filemenager-preview card">
  56. <div class="no-image">
  57. <i class="fa fa-image"></i>
  58. </div>
  59. <img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top">
  60. </div>
  61. </div>
  62. <div class="col-12">
  63. <div class="input-group">
  64. <div class="input-group-prepend">
  65. {% if form.parent.vars['row_attr']['data-sortable'] is defined %}
  66. <button type="button" class="btn btn-success lc-btn-sortable" data-toggle="tooltip"
  67. title="Trier les images">
  68. <i class="fa fa-arrows-alt"></i>
  69. </button>
  70. {% endif %}
  71. <button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}"
  72. data-toggle="tooltip" title="Sélectionner un fichier"
  73. data-target="{{ path('file_manager', {module:1, conf:'default'})|raw }}">
  74. <i class="fa fa-folder-open"></i>
  75. </button>
  76. </div>
  77. {{ form_widget(form.legend) }}
  78. <div class="input-group-append">
  79. <button type="button" class="btn btn-danger lc-filemanager-delete" data-toggle="tooltip"
  80. title="Supprimer l'image"
  81. data-id="{{ form.path.vars.id }}">
  82. <i class="fa fa-trash"></i>
  83. </button>
  84. </div>
  85. {{ form_rest(form) }}
  86. </div>
  87. </div>
  88. </div>
  89. {% endblock file_manager_widget %}
  90. {% block checkbox_radio_label -%}
  91. {#- Do not display the label if widget is not defined in order to prevent double label rendering -#}
  92. {%- if widget is defined -%}
  93. {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %}
  94. {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %}
  95. {%- if is_parent_custom or is_custom -%}
  96. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' custom-control-label')|trim}) -%}
  97. {%- else %}
  98. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-check-label')|trim}) -%}
  99. {%- endif %}
  100. {%- if not compound -%}
  101. {% set label_attr = label_attr|merge({'for': id}) %}
  102. {%- endif -%}
  103. {%- if required -%}
  104. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
  105. {%- endif -%}
  106. {%- if parent_label_class is defined -%}
  107. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|replace({'checkbox-inline': '', 'radio-inline': '', 'checkbox-custom': '', 'radio-custom': ''})|trim}) -%}
  108. {%- endif -%}
  109. {%- if label is not same as(false) and label is empty -%}
  110. {%- if label_format is not empty -%}
  111. {%- set label = label_format|replace({
  112. '%name%': name,
  113. '%id%': id,
  114. }) -%}
  115. {%- else -%}
  116. {%- set label = name|humanize -%}
  117. {%- endif -%}
  118. {%- endif -%}
  119. <label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
  120. {{ widget|raw }}
  121. <span class="checkmark"></span>
  122. {# {% if translation_domain == 'lcshop' %}
  123. {{ name|lc_trad(easyadmin['entity']['name'], 'field') }}
  124. {% else %} #}
  125. {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}}
  126. {# {% endif %} #}
  127. {{- form_errors(form) -}}
  128. </label>
  129. {%- endif -%}
  130. {%- endblock checkbox_radio_label %}
  131. {% block form_start %}
  132. {{ parent() }}
  133. {% if ea_crud_form.form_panels is defined %}
  134. <div class="card card-outline">
  135. <div class="card-header p-0 border-bottom-0">
  136. <ul id="nav-params" class="nav nav-pills" role="navigation">
  137. {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %}
  138. {% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %}
  139. <li class="nav-item">
  140. <a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" data-toggle="tab" role="tab"
  141. aria-controls="panel-{{ panel_name }}">
  142. {{ panel_config.label|raw }}
  143. <i class="fa fa-exclamation-circle invalid-form"></i>
  144. </a>
  145. </li>
  146. {% endfor %}
  147. </ul>
  148. </div>
  149. </div>
  150. {% endif %}
  151. {% endblock form_start %}
  152. {% block ea_crud_widget_panels %}
  153. <div class="tab-content">
  154. {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %}
  155. {% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %}
  156. {% set collapsible = panel_config.collapsible %}
  157. {% set collapsed = panel_config.collapsed %}
  158. <div class="tab-pane {{ panel_name == 1 ? 'active' }}" id="panel-{{ panel_name }}"
  159. aria-labelledby="{{ panel_name }}-tab">
  160. {% if panel_config.template is defined and panel_config.template is not null %}
  161. {% include panel_config.template %}
  162. {% else %}
  163. <div class="card {{ panel_config.css_class ?? '' }}">
  164. <div class="card-status-top bg-primary"></div>
  165. <div class="card-header ">
  166. {% if panel_has_header %}
  167. {# <div class="content-panel-header {{ collapsible ? 'collapsible' }} {{ panel_config.help|default(false) is not empty ? 'with-help' }}"> #}
  168. {% if collapsible %}
  169. <a href="#content-{{ panel_name }}" data-toggle="collapse" class="content-panel-collapse {{ collapsed ? 'collapsed' }}" aria-expanded="{{ collapsed ? 'false' : 'true' }}" aria-controls="content-{{ panel_name }}">
  170. <i class="fas fw fa-chevron-right collapse-icon"></i>
  171. {% endif %}
  172. {% if panel_config.icon|default(false) %}
  173. <i class="{{ panel_config.icon }}"></i>
  174. {% endif %}
  175. {{ panel_config.label|raw }}
  176. {% if collapsible %}
  177. </a>
  178. {% endif %}
  179. {% if panel_config.help|default(false) %}
  180. <div class="content-panel-header-help">{{ panel_config.help|raw }}</div>
  181. {% endif %}
  182. {% endif %}
  183. </div>
  184. <div class="card-body {{ collapsible ? 'collapse' }} {{ not collapsed ? 'show' }}">
  185. {% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and field.vars.ea_crud_form.form_panel == panel_name) %}
  186. {% if not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name %}
  187. {{ form_row(field) }}
  188. {% endif %}
  189. {% endfor %}
  190. </div>
  191. </div>
  192. {% endif %}
  193. </div>
  194. {% else %}
  195. <div class="card">
  196. <div class="card-status-top bg-primary"></div>
  197. <div class="card-header "></div>
  198. <div class="card-body">
  199. {% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and (not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name)) %}
  200. {{ form_row(field) }}
  201. {% endfor %}
  202. </div>
  203. </div>
  204. {% endfor %}
  205. </div>
  206. {% endblock ea_crud_widget_panels %}