Show entity preview image on admin page

This commit is contained in:
Jan Böhmer 2023-02-05 20:00:11 +01:00
parent d3023ea945
commit a925597565
5 changed files with 22 additions and 5 deletions

View file

@ -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 %}
<span class="float-end">{% block quick_links %}{% endblock %}</span>
<div class="float-end">
{% block quick_links %}{% endblock %}
{% block preview_picture %}
{{ helper.entity_preview_sm(entity) }}
{% endblock %}
</div>
{% else %}
<strong>{% block new_title %}{% trans %}new.caption{% endtrans %}{% endblock %}</strong>
{% endif %}

View file

@ -19,7 +19,7 @@
{% endblock %}
{% block quick_links %}
<div class="btn-toolbar">
<div class="btn-toolbar" style="display: inline-block;">
<div class="btn-group">
<a class="btn btn-outline-secondary" href="{{ entity_url(entity) }}"><i class="fas fa-eye fa-fw"></i></a>
</div>

View file

@ -87,6 +87,6 @@
{% trans %}user.new{% endtrans %}
{% endblock %}
{% block quick_links %}
<img src="{{ avatar_helper.avatarURL(entity) }}" style="height: 50px; width: 50px; object-fit: cover;">
{% block preview_picture %}
<img src="{{ avatar_helper.avatarURL(entity) }}" style="height: 50px;">
{% endblock %}

View file

@ -1,6 +1,6 @@
{# Renders an btn toolbar to quickly call/email or visit the website of a company #}
{% macro company(entity) %}
<div class="btn-toolbar">
<div class="btn-toolbar" style="display: inline-block;">
<div class="btn-group">
{% if entity.website is not empty %}
<a class="btn btn-outline-secondary" href="{{ entity.website }}" title="{% trans %}company.edit.quick.website{% endtrans %}" target="_blank" rel="nofollow"><i class="fas fa-globe fa-fw"></i></a>

View file

@ -172,6 +172,15 @@
<img src="{{ avatar_helper.avatarSmURL(user) }}" class="rounded" style="height: 1.2rem;" alt="User avatar" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ avatar_helper.avatarMdURL(user) }}">
{% 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) %}
<a href="{{ entity_url(entity.masterPictureAttachment, 'file_view') }}" target="_blank" title="{{ entity.masterPictureAttachment.name}}">
<img src="{{ attachment_thumbnail(entity.masterPictureAttachment, 'thumbnail_sm') }}" style="height: 50px;">
</a>
{% endif %}
{% endmacro %}
{% macro parameters_table(parameters) %}
<table class="table table-hover table-striped table-sm">
<thead>