From 76a91eb9e6bb4e52b7891500fd185992274e70f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 7 Jan 2026 10:26:19 +0100 Subject: [PATCH 1/3] Allowed using `table.html.twig` in Twig's `embed` --- .../table/empty_table_body_row.html.twig | 2 + .../table/empty_table_extra_actions.html.twig | 2 + .../admin/ui/component/table/table.html.twig | 93 ++++++++++--------- .../component/table/table_body_cell.html.twig | 5 +- .../component/table/table_body_row.html.twig | 10 +- .../component/table/table_head_cell.html.twig | 5 +- .../component/table/table_head_row.html.twig | 8 +- .../ui/component/table/table_header.html.twig | 4 +- 8 files changed, 80 insertions(+), 49 deletions(-) diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_body_row.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_body_row.html.twig index cd8c44d0a5..1f6f74fd05 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_body_row.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_body_row.html.twig @@ -1,3 +1,4 @@ +{% block empty_table_body_row %} +{% endblock %} diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_extra_actions.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_extra_actions.html.twig index 99c2ce0b45..07c9146fd3 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_extra_actions.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/empty_table_extra_actions.html.twig @@ -1,3 +1,4 @@ +{% block empty_table_extra_actions %}
{% block extra_action_link %} @@ -10,3 +11,4 @@ {% endblock %}
+{% endblock %} diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig index 3e7d013cb0..85e79de7ef 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig @@ -1,19 +1,11 @@ -{% import "@ibexadesign/ui/component/macros.html.twig" as html %} - -{% set show_head_cols_if_empty = show_head_cols_if_empty|default(false) %} - -{% if is_last_column_sticky is not defined %} - {% if body_rows is defined %} - {% set no_action_cell_rows = body_rows|filter((row) => not (row.cols|last).has_action_btns|default(false)) %} - {% set is_last_column_sticky = no_action_cell_rows|length == 0 %} - {% else %} - {% set is_last_column_sticky = false %} - {% endif %} -{% endif %} +{% use '@ibexadesign/ui/component/table/table_body_row.html.twig' %} +{% use '@ibexadesign/ui/component/table/table_head_row.html.twig' %} +{% use '@ibexadesign/ui/component/table/table_header.html.twig' %} +{% use '@ibexadesign/ui/component/table/empty_table_body_row.html.twig' %} {% block header %} {% if headline is defined %} - {% include '@ibexadesign/ui/component/table/table_header.html.twig' with { + {% with { headline, actions: actions|default(null), headline_title: headline_title|default(''), @@ -21,7 +13,9 @@ notice_message: notice_message|default(''), notice_icon: notice_icon|default('about-info'), show_notice: show_notice|default(false), - } only %} + } %} + {{ block('table_header') }} + {% endwith %} {% endif %} {% endblock %} @@ -29,61 +23,74 @@ {% block table %} {% set table_content %} + {% import "@ibexadesign/ui/component/macros.html.twig" as html %} + {% set show_head_cols_if_empty = show_head_cols_if_empty|default(false) %} + {% if is_last_column_sticky is not defined %} + {% if body_rows is defined %} + {% set no_action_cell_rows = body_rows|filter((row) => not (row.cols|last).has_action_btns|default(false)) %} + {% set is_last_column_sticky = no_action_cell_rows|length == 0 %} + {% else %} + {% set is_last_column_sticky = false %} + {% endif %} + {% endif %} + {% set empty_row %} {% block tbody_empty %} - {% include '@ibexadesign/ui/component/table/empty_table_body_row.html.twig' with { + {% with { colspan: head_cols|length, empty_image: empty_image|default(asset('/bundles/ibexaadminui/img/ibexa-empty-table.svg')) } %} + {{ block('empty_table_body_row') }} + {% endwith %} {% endblock %} {% endset %} - {% block thead %} - {% if head_cols is defined %} - {% include '@ibexadesign/ui/component/table/table_head_row.html.twig' with { - head_cols, - } %} - {% endif %} - {% endblock %} + {% block thead %} + {% if head_cols is defined %} + {{ block('table_head_row') }} + {% endif %} + {% endblock %} - {% block tbody %} + {% block tbody %} - {% if body_rows is defined %} - {% if body_rows is empty %} - {{ empty_row }} - {% else %} - {% block tbody_not_empty %} - {% for row in body_rows %} - {% include '@ibexadesign/ui/component/table/table_body_row.html.twig' with { - body_row_cols: row.cols, - class: row.class|default(''), - attr: row.attr|default({}), - } %} - {% endfor %} - {% endblock %} - {% endif %} + {% if body_rows is defined %} + {% if body_rows is empty %} + {{ empty_row }} + {% else %} + {% block tbody_not_empty %} + {% for row in body_rows %} + {% with { + body_row_cols: row.cols, + class: row.class|default(''), + attr: row.attr|default({}), + } %} + {{ block('table_body_row') }} + {% endwith %} + {% endfor %} + {% endblock %} {% endif %} - {% endblock %} + {% endif %} + {% endblock %}
{% endset %} - {% if is_scrollable is defined ? is_scrollable : true %} + {% if is_scrollable|default(true) %}
{{ table_content }}
diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_cell.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_cell.html.twig index 45981792e5..26ff345520 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_cell.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_cell.html.twig @@ -1,5 +1,5 @@ +{% block table_body_cell %} {% import "@ibexadesign/ui/component/macros.html.twig" as html %} -{% import "@ibexadesign/ui/component/table/table_macros.html.twig" as table_macros %} {%- block action_btns_content -%} + {% import "@ibexadesign/ui/component/table/table_macros.html.twig" as table_macros %} {{- table_macros.conditional_escape(content, raw|default(false)) -}} {%- endblock -%} @@ -23,3 +25,4 @@ {%- endif -%} {%- endblock -%} +{% endblock %} diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_row.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_row.html.twig index a770ad7ac0..e3950bb5a2 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_row.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/table_body_row.html.twig @@ -1,3 +1,6 @@ +{% use '@ibexadesign/ui/component/table/table_body_cell.html.twig' %} + +{% block table_body_row %} {% import "@ibexadesign/ui/component/macros.html.twig" as html %} +{% endblock %} diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/table_head_row.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/table_head_row.html.twig index 3036e546a7..d70586acfd 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/table_head_row.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/table_head_row.html.twig @@ -1,7 +1,10 @@ +{% use '@ibexadesign/ui/component/table/table_head_cell.html.twig' %} + +{% block table_head_row %} {% block cells %} {% for head_col in head_cols %} - {% include '@ibexadesign/ui/component/table/table_head_cell.html.twig' with { + {% with { has_checkbox: head_col.has_checkbox|default(false), is_custom_bulk: head_col.is_custom_bulk|default(false), has_icon: head_col.has_icon|default(false), @@ -13,7 +16,10 @@ attr: head_col.attr|default({}), wrapper_attr: head_col.wrapper_attr|default({}), } %} + {{ block('table_head_cell') }} + {% endwith %} {% set next_is_close_left = head_col.has_checkbox|default(false) or head_col.has_icon|default(false) %} {% endfor %} {% endblock %} +{% endblock %} diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/table_header.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/table_header.html.twig index 04a35423a0..0b12775a23 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/table_header.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/table_header.html.twig @@ -1,3 +1,4 @@ +{% block table_header %}
-
\ No newline at end of file +
+{% endblock %} From e5e65382f9ba25c0b3800aff0a3949de9c4c4a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 7 Jan 2026 10:45:28 +0100 Subject: [PATCH 2/3] Allowed using `table.html.twig` in Twig's `embed` --- .../views/themes/admin/ui/component/table/table.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig index 85e79de7ef..50de479bef 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/table/table.html.twig @@ -46,10 +46,10 @@ {% endset %}