From 12e7deb0af49aadd23ebdf901bebae827482dcd4 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Mon, 28 Oct 2024 09:27:09 +0100 Subject: [PATCH] feat(areabrick-overview): display number of (un)published pages (#32) --- templates/bricks/overview.html.twig | 45 +++++++--------------- templates/bricks/pages_accordion.html.twig | 14 +++++++ 2 files changed, 27 insertions(+), 32 deletions(-) create mode 100644 templates/bricks/pages_accordion.html.twig diff --git a/templates/bricks/overview.html.twig b/templates/bricks/overview.html.twig index 5a0072e..907da4f 100644 --- a/templates/bricks/overview.html.twig +++ b/templates/bricks/overview.html.twig @@ -22,39 +22,20 @@ {{ brick.description|trans }} {{ brick.template }} - {% set published_pages = brick.pages|filter(page => page.published) %} - {% set unpublished_pages = brick.pages|filter(page => not page.published) %} + {% embed "@NeustaPimcoreAreabrickConfig/bricks/pages_accordion.html.twig" with { + title: 'neusta_pimcore_areabrick_config.areabricks.overview.table.published_pages'|trans, + pages: brick.pages|filter(page => page.published), + } only %} + {% block page %} + {{ parent() }} (Frontend) + {% endblock %} + {% endembed %} - {% if published_pages is not empty %} -
- {{ 'neusta_pimcore_areabrick_config.areabricks.overview.table.published_pages'|trans }} - -
- {% endif %} - - {% if unpublished_pages is not empty %} -
- {{ 'neusta_pimcore_areabrick_config.areabricks.overview.table.unpublished_pages'|trans }} - -
- {% endif %} + {% embed "@NeustaPimcoreAreabrickConfig/bricks/pages_accordion.html.twig" with { + title: 'neusta_pimcore_areabrick_config.areabricks.overview.table.unpublished_pages'|trans, + pages: brick.pages|filter(page => not page.published), + } only %} + {% endembed %} {% if hasAdditionalProperties %} diff --git a/templates/bricks/pages_accordion.html.twig b/templates/bricks/pages_accordion.html.twig new file mode 100644 index 0000000..d058127 --- /dev/null +++ b/templates/bricks/pages_accordion.html.twig @@ -0,0 +1,14 @@ +{% if pages is not empty %} +
+ {{ title }} ({{ pages|length }}) + +
+{% endif %}