vendor/easycorp/easyadmin-bundle/src/Resources/views/crud/detail.html.twig line 1

Open in your IDE?
  1. {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
  2. {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
  3. {% extends ea.templatePath('layout') %}
  4. {% block body_id 'ea-detail-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %}
  5. {% block body_class 'ea-detail ea-detail-' ~ entity.name %}
  6. {% set ea_field_assets = ea.crud.fieldAssets(constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Crud::PAGE_DETAIL')) %}
  7. {% block configured_head_contents %}
  8.     {{ parent() }}
  9.     {% for htmlContent in ea_field_assets.headContents %}
  10.         {{ htmlContent|raw }}
  11.     {% endfor %}
  12. {% endblock %}
  13. {% block configured_body_contents %}
  14.     {{ parent() }}
  15.     {% for htmlContent in ea_field_assets.bodyContents %}
  16.         {{ htmlContent|raw }}
  17.     {% endfor %}
  18. {% endblock %}
  19. {% block configured_stylesheets %}
  20.     {{ parent() }}
  21.     {{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }}
  22.     {{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }}
  23. {% endblock %}
  24. {% block configured_javascripts %}
  25.     {{ parent() }}
  26.     {{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }}
  27.     {{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }}
  28. {% endblock %}
  29. {% block content_title %}
  30.     {%- apply spaceless -%}
  31.         {% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %}
  32.         {{ custom_page_title is null
  33.             ? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw
  34.             : custom_page_title|trans|raw }}
  35.     {%- endapply -%}
  36. {% endblock %}
  37. {% block page_actions %}
  38.     {% for action in entity.actions %}
  39.         {{ include(action.templatePath, { action: action }, with_context = false) }}
  40.     {% endfor %}
  41. {% endblock %}
  42. {% block content_footer_wrapper '' %}
  43. {% block main %}
  44.     {% block detail_fields %}
  45.         {% set form_panel_is_already_open = false %}
  46.         {% for field in entity.fields %}
  47.             {% set is_form_field_panel = 'field-form_panel' in field.cssClass %}
  48.             {% if is_form_field_panel or (loop.first and not is_form_field_panel) %}
  49.                 {% if form_panel_is_already_open %}
  50.                     {{ _self.close_form_field_panel() }}
  51.                     {% set form_panel_is_already_open = false %}
  52.                 {% endif %}
  53.                 {{ _self.open_form_field_panel(is_form_field_panel ? field : null) }}
  54.                 {% set form_panel_is_already_open = true %}
  55.             {% endif %}
  56.             {% block detail_field %}
  57.                 {% if not is_form_field_panel %}
  58.                     {{ _self.render_field(entity, field) }}
  59.                 {% endif %}
  60.             {% endblock %}
  61.         {% endfor %}
  62.         {{ _self.close_form_field_panel() }}
  63.     {% endblock %}
  64.     {% block delete_form %}
  65.         {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }}
  66.     {% endblock delete_form %}
  67. {% endblock %}
  68. {% macro open_form_field_panel(field = null) %}
  69.     {% set panel_name = field is null ? null : 'content-' ~ field.uniqueId %}
  70.     {% set collapsible = field is null ? false : field.customOption('collapsible') %}
  71.     {% set collapsed = field is null ? false : field.customOption('collapsed') %}
  72.     {% set panel_icon = field is null ? null : (field.customOptions.get('icon')|default(false)) %}
  73.     {% set panel_label = field is null ? null : field.label %}
  74.     {% set panel_help = field is null ? null : field.help|default(false)%}
  75.     {% set panel_has_header = collapsible or panel_icon or panel_label or panel_help %}
  76.     <div class="{{ field.cssClass ?? '' }}">
  77.         <div class="form-panel">
  78.             {% if panel_has_header %}
  79.                 <div class="form-panel-header {{ collapsible ? 'collapsible' }} {{ panel_help is not empty ? 'with-help' }}">
  80.                     <div class="form-panel-title">
  81.                         <a {% if not collapsible %}
  82.                             href="#" class="not-collapsible"
  83.                         {% else %}
  84.                             href="#{{ panel_name }}" data-bs-toggle="collapse"
  85.                             class="form-panel-collapse {{ collapsed ? 'collapsed' }}"
  86.                             aria-expanded="{{ collapsed ? 'false' : 'true' }}" aria-controls="{{ panel_name }}"
  87.                         {% endif %}
  88.                         >
  89.                             {% if collapsible %}
  90.                                 <i class="fas fw fa-chevron-right form-panel-collapse-marker"></i>
  91.                             {% endif %}
  92.                             {% if panel_icon %}
  93.                                 <i class="form-panel-icon {{ panel_icon }}"></i>
  94.                             {% endif %}
  95.                             {{ panel_label|trans|raw }}
  96.                         </a>
  97.                         {% if panel_help %}
  98.                             <div class="form-panel-help">{{ panel_help|raw }}</div>
  99.                         {% endif %}
  100.                     </div>
  101.                 </div>
  102.             {% endif %}
  103.             <div {% if panel_name %}id="{{ panel_name }}"{% endif %} class="form-panel-body {{ collapsible ? 'collapse' }} {{ not collapsed ? 'show'}}">
  104.                 <dl class="datalist">
  105. {% endmacro %}
  106. {% macro close_form_field_panel() %}
  107.             </dl>
  108.         </div>
  109.     </div>
  110. </div>
  111. {% endmacro %}
  112. {% macro render_field(entity, field) %}
  113.     <div class="data-row {{ field.cssClass }}">
  114.         <dt>
  115.             {{ field.label|trans|raw }}
  116.             {% if field.help is not empty %}
  117.                 <a tabindex="0" class="data-help" data-bs-toggle="popover" data-bs-custom-class="ea-content-help-popover" data-bs-animation="true" data-bs-html="true" data-bs-placement="right" data-bs-trigger="focus" data-bs-content="{{ field.help|trans|e('html_attr') }}">
  118.                     <i class="far fa-question-circle"></i>
  119.                 </a>
  120.             {% endif %}
  121.         </dt>
  122.         <dd>
  123.             {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  124.         </dd>
  125.     </div>
  126. {% endmacro %}