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

  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.     {% set field_layout = ea_create_field_layout(entity.fields) %}
  45.     {% block detail_fields %}
  46.         {% if field_layout.hasTabs %}
  47.             {{ _self.render_detail_fields_with_tabs(entity, field_layout) }}
  48.         {% else %}
  49.             {{ _self.render_detail_fields(entity, field_layout.fields) }}
  50.         {% endif %}
  51.     {% endblock detail_fields %}
  52.     {% block delete_form %}
  53.         {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }}
  54.     {% endblock delete_form %}
  55. {% endblock %}
  56. {% macro render_detail_fields_with_tabs(entity, field_layout) %}
  57.     <div class="col-12">
  58.         <div class="nav-tabs-custom form-tabs">
  59.             <ul class="nav nav-tabs">
  60.                 {% for tab in field_layout.tabs %}
  61.                     <li class="nav-item">
  62.                         <a class="nav-link {% if loop.first %}active{% endif %}" href="#tab-pane-{{ tab.uniqueId }}" id="tab-{{ tab.uniqueId }}" data-bs-toggle="tab">
  63.                             {%- if tab.customOption('icon') -%}
  64.                                 <i class="fa-fw {{ tab.customOption('icon') }}"></i>
  65.                             {%- endif -%}
  66.                             {{ tab.label|trans(domain = ea.i18n.translationDomain)|raw }}
  67.                         </a>
  68.                     </li>
  69.                 {% endfor %}
  70.             </ul>
  71.             <div class="tab-content">
  72.                 {% for tab in field_layout.tabs %}
  73.                     <div id="tab-pane-{{ tab.uniqueId }}" class="tab-pane {% if loop.first %}active{% endif %} {{ tab.cssClass|default('') }}">
  74.                         {% if tab.help|default(false) %}
  75.                             <div class="content-header-help tab-help">
  76.                                 {{ tab.help|trans(domain = ea.i18n.translationDomain)|raw }}
  77.                             </div>
  78.                         {% endif %}
  79.                         <div class="row">
  80.                             {{ _self.render_detail_fields(entity, field_layout.fieldsInTab(tab.uniqueId)) }}
  81.                         </div>
  82.                     </div>
  83.                 {% endfor %}
  84.             </div>
  85.         </div>
  86.     </div>
  87. {% endmacro %}
  88. {% macro render_detail_fields(entity, fields) %}
  89.     {% set form_panel_is_already_open = false %}
  90.     {% for field in fields %}
  91.         {% set is_form_field_panel = 'field-form_panel' in field.cssClass %}
  92.         {% if is_form_field_panel or (loop.first and not is_form_field_panel) %}
  93.             {% if form_panel_is_already_open %}
  94.                 {{ _self.close_form_field_panel() }}
  95.                 {% set form_panel_is_already_open = false %}
  96.             {% endif %}
  97.             {{ _self.open_form_field_panel(is_form_field_panel ? field : null) }}
  98.             {% set form_panel_is_already_open = true %}
  99.         {% endif %}
  100.         {% block detail_field %}
  101.             {% if not is_form_field_panel %}
  102.                 {{ _self.render_field(entity, field) }}
  103.             {% endif %}
  104.         {% endblock %}
  105.     {% endfor %}
  106.     {% if form_panel_is_already_open %}
  107.         {{ _self.close_form_field_panel() }}
  108.         {% set form_panel_is_already_open = false %}
  109.     {% endif %}
  110. {% endmacro %}
  111. {% macro open_form_field_panel(field = null) %}
  112.     {% set panel_name = field is null ? null : 'content-' ~ field.uniqueId %}
  113.     {% set collapsible = field is null ? false : field.customOption('collapsible') %}
  114.     {% set collapsed = field is null ? false : field.customOption('collapsed') %}
  115.     {% set panel_icon = field is null ? null : (field.customOptions.get('icon')|default(false)) %}
  116.     {% set panel_label = field is null ? null : field.label %}
  117.     {% set panel_help = field is null ? null : field.help|default(false)%}
  118.     {% set panel_has_header = collapsible or panel_icon or panel_label or panel_help %}
  119.     <div class="{{ field.cssClass ?? '' }}">
  120.         <div class="form-panel">
  121.             {% if panel_has_header %}
  122.                 <div class="form-panel-header {{ collapsible ? 'collapsible' }} {{ panel_help is not empty ? 'with-help' }}">
  123.                     <div class="form-panel-title">
  124.                         <a {% if not collapsible %}
  125.                             href="#" class="not-collapsible"
  126.                         {% else %}
  127.                             href="#{{ panel_name }}" data-bs-toggle="collapse"
  128.                             class="form-panel-collapse {{ collapsed ? 'collapsed' }}"
  129.                             aria-expanded="{{ collapsed ? 'false' : 'true' }}" aria-controls="{{ panel_name }}"
  130.                         {% endif %}
  131.                         >
  132.                             {% if collapsible %}
  133.                                 <i class="fas fw fa-chevron-right form-panel-collapse-marker"></i>
  134.                             {% endif %}
  135.                             {% if panel_icon %}
  136.                                 <i class="form-panel-icon {{ panel_icon }}"></i>
  137.                             {% endif %}
  138.                             {{ panel_label|trans|raw }}
  139.                         </a>
  140.                         {% if panel_help %}
  141.                             <div class="form-panel-help">{{ panel_help|trans|raw }}</div>
  142.                         {% endif %}
  143.                     </div>
  144.                 </div>
  145.             {% endif %}
  146.             <div {% if panel_name %}id="{{ panel_name }}"{% endif %} class="form-panel-body {{ collapsible ? 'collapse' }} {{ not collapsed ? 'show'}}">
  147.                 <dl class="datalist">
  148. {% endmacro %}
  149. {% macro close_form_field_panel() %}
  150.             </dl>
  151.         </div>
  152.     </div>
  153. </div>
  154. {% endmacro %}
  155. {% macro render_field(entity, field) %}
  156.     <div class="data-row {{ field.cssClass }}">
  157.         <dt>
  158.             {{ field.label|trans|raw }}
  159.             {% if field.help is not empty %}
  160.                 <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') }}">
  161.                     <i class="far fa-question-circle"></i>
  162.                 </a>
  163.             {% endif %}
  164.         </dt>
  165.         <dd>
  166.             {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  167.         </dd>
  168.     </div>
  169. {% endmacro %}