From a925597565c312ca7c96c7df9022281bd4b6df51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 5 Feb 2023 20:00:11 +0100 Subject: [PATCH] Show entity preview image on admin page --- templates/admin/base_admin.html.twig | 10 +++++++++- templates/admin/project_admin.html.twig | 2 +- templates/admin/user_admin.html.twig | 4 ++-- templates/components/quick_links.macro.html.twig | 2 +- templates/helper.twig | 9 +++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/templates/admin/base_admin.html.twig b/templates/admin/base_admin.html.twig index cdb1adf8..a42eb8d5 100644 --- a/templates/admin/base_admin.html.twig +++ b/templates/admin/base_admin.html.twig @@ -1,4 +1,7 @@ {% import "components/tree_macros.html.twig" as tree %} +{% import "helper.twig" as helper %} + +{# @var entity \App\Entity\Base\AbstractStructuralDBElement #} {% extends "main_card.html.twig" %} @@ -38,7 +41,12 @@ {% if timeTravel is defined and timeTravel is not null %} ({{ timeTravel|format_datetime('short') }}) {% endif %} - {% block quick_links %}{% endblock %} +
+ {% block quick_links %}{% endblock %} + {% block preview_picture %} + {{ helper.entity_preview_sm(entity) }} + {% endblock %} +
{% else %} {% block new_title %}{% trans %}new.caption{% endtrans %}{% endblock %} {% endif %} diff --git a/templates/admin/project_admin.html.twig b/templates/admin/project_admin.html.twig index 071340bf..9babf51d 100644 --- a/templates/admin/project_admin.html.twig +++ b/templates/admin/project_admin.html.twig @@ -19,7 +19,7 @@ {% endblock %} {% block quick_links %} -
+
diff --git a/templates/admin/user_admin.html.twig b/templates/admin/user_admin.html.twig index 69003339..322ae33d 100644 --- a/templates/admin/user_admin.html.twig +++ b/templates/admin/user_admin.html.twig @@ -87,6 +87,6 @@ {% trans %}user.new{% endtrans %} {% endblock %} -{% block quick_links %} - +{% block preview_picture %} + {% endblock %} \ No newline at end of file diff --git a/templates/components/quick_links.macro.html.twig b/templates/components/quick_links.macro.html.twig index f0c04bff..04620aae 100644 --- a/templates/components/quick_links.macro.html.twig +++ b/templates/components/quick_links.macro.html.twig @@ -1,6 +1,6 @@ {# Renders an btn toolbar to quickly call/email or visit the website of a company #} {% macro company(entity) %} -
+
{% if entity.website is not empty %} diff --git a/templates/helper.twig b/templates/helper.twig index f7a259bc..2e762491 100644 --- a/templates/helper.twig +++ b/templates/helper.twig @@ -172,6 +172,15 @@ User avatar {% endmacro %} +{% macro entity_preview_sm(entity) %} + {# @var entity \App\Entity\Contracts\HasMasterAttachmentInterface #} + {% if entity.masterPictureAttachment and entity.masterPictureAttachment.picture and attachment_manager.fileExisting(entity.masterPictureAttachment) %} + + + + {% endif %} +{% endmacro %} + {% macro parameters_table(parameters) %}