Refactored TwigExtensions Part 1

This commit is contained in:
Jan Böhmer 2022-09-18 16:45:12 +02:00
parent 8e6300079a
commit b078389381
21 changed files with 301 additions and 89 deletions

View file

@ -57,12 +57,12 @@
</td>
<td><div class="btn-group" role="group" aria-label="">
<a {% if attachment_manager.fileExisting(attachment) %}href="{{ attachment|entityURL('file_view') }}"{% endif %} target="_blank"
<a {% if attachment_manager.fileExisting(attachment) %}href="{{ entity_url(attachment, 'file_view') }}"{% endif %} target="_blank"
class="btn btn-secondary {% if not attachment_manager.fileExisting(attachment) or (attachment.secure and not is_granted("show_secure", attachment)) %}disabled{% endif %}"
data-turbo="false" title="{% trans %}attachment.view{% endtrans %}" rel="noopener">
<i class="fas fa-eye fa-fw"></i>
</a>
<a {% if attachment_manager.fileExisting(attachment) %}href="{{ attachment|entityURL('file_download') }}"{% endif %} data-turbo="false"
<a {% if attachment_manager.fileExisting(attachment) %}href="{{ entity_url(attachment, 'file_download') }}"{% endif %} data-turbo="false"
class="btn btn-secondary {% if not attachment_manager.fileExisting(attachment) or (attachment.secure and not is_granted("show_secure", attachment)) %}disabled{% endif %}"
title="{% trans %}attachment.download{% endtrans %}">
<i class="fas fa-download fa-fw"></i>

View file

@ -10,7 +10,7 @@
<tr>
<td>{% trans %}user.creating_user{% endtrans %}</td>
<td>{% if is_granted('show_users', part) %}
{{ getCreatingUser(part).fullName(true) ?? 'Unknown'|trans }}
{{ creating_user(part).fullName(true) ?? 'Unknown'|trans }}
{% else %}
{% trans %}accessDenied{% endtrans %}
{% endif %}
@ -25,7 +25,7 @@
<tr>
<td>{% trans %}user.last_editing_user{% endtrans %}</td>
<td>{% if is_granted('show_users', part) %}
{{ getLastEditingUser(part).fullName(true) ?? 'Unknown'|trans }}
{{ last_editing_user(part).fullName(true) ?? 'Unknown'|trans }}
{% else %}
{% trans %}accessDenied{% endtrans %}
{% endif %}

View file

@ -8,7 +8,7 @@
<h5 class="text-muted pt-2" title="{% trans %}manufacturer.label{% endtrans %}">
{% if part.manufacturer %}
{% if part.manufacturer.id is not null %}
<a href="{{ part.manufacturer | entityURL('list_parts') }}">{{ part.manufacturer.name}}</a>
<a href="{{ entity_url(part.manufacturer, 'list_parts') }}">{{ part.manufacturer.name}}</a>
{% else %}
{{ part.manufacturer.name }}
{% endif %}
@ -24,9 +24,9 @@
<h3 class="w-fit" title="{% trans %}name.label{% endtrans %}">{{ part.name }}
{# You need edit permission to use the edit button #}
{% if timeTravel is not null %}
<a href="{{ part|entityURL('info') }}"><i title="{% trans %}part.back_to_info{% endtrans %}" class="fas fa-fw fa-arrow-circle-left"></i></a>
<a href="{{ entity_url(part, 'info') }}"><i title="{% trans %}part.back_to_info{% endtrans %}" class="fas fa-fw fa-arrow-circle-left"></i></a>
{% elseif is_granted('edit', part) %}
<a href="{{ part|entityURL('edit') }}"><i class="fas fa-fw fa-sm fa-edit"></i></a>
<a href="{{ entity_url(part, 'edit') }}"><i class="fas fa-fw fa-sm fa-edit"></i></a>
{% endif %}
</h3>
<h6 class="text-muted w-fit" title="{% trans %}description.label{% endtrans %}"><span>{{ part.description|markdown(true) }}</span></h6>

View file

@ -12,7 +12,7 @@
{% for order in part.orderdetails %}
<tr class="{% if order.obsolete %}table-danger{% endif %}">
<td>
<a href="{{ order.supplier | entityURL('list_parts') }}">{{ order.supplier.name }}</a>
<a href="{{ entity_url(order.supplier, 'list_parts') }}">{{ order.supplier.name }}</a>
</td>
<td>{% if order.supplierProductUrl is not empty %}
<a href="{{ order.supplierProductUrl }}" rel="noopener" target="_blank" class="link-external">{{ order.supplierPartNr }}</a>

View file

@ -11,8 +11,8 @@
{% for pic in pictures %}
{# @var pic App\Entity\Attachments\Attachment #}
<div class="carousel-item {% if loop.first %}active{% endif %}">
<a href="{{ pic | entityURL('file_view') }}" data-turbo="false" target="_blank" rel="noopener">
<img class="d-block w-100 img-fluid img-thumbnail bg-light" src="{{ pic | entityURL('file_view') }}" alt="">
<a href="{{ entity_url(pic, 'file_view') }}" data-turbo="false" target="_blank" rel="noopener">
<img class="d-block w-100 img-fluid img-thumbnail bg-light" src="{{ entity_url(pic, 'file_view') }}" alt="">
<div class="mask"></div>
<div class="carousel-caption-hover">
<div class="carousel-caption">

View file

@ -1,7 +1,7 @@
{% import "LabelSystem/dropdown_macro.html.twig" as dropdown %}
{% if is_granted('edit', part) %}
<a href="{{ part|entityURL('edit') }}" class="btn btn-primary mt-3">
<a href="{{ entity_url(part, 'edit') }}" class="btn btn-primary mt-3">
<i class="fas fa-fw fa-edit"></i>
{% trans %}part.edit.btn{% endtrans %}
</a>
@ -11,7 +11,7 @@
{% if is_granted('create', part) %}
<br>
<div class="btn-group mt-2">
<a class="btn btn-primary" href="{{ part|entityURL('clone') }}">
<a class="btn btn-primary" href="{{ entity_url(part, 'clone') }}">
<i class="fas fa-clone"></i>
{% trans %}part.clone.btn{% endtrans %}
</a>
@ -19,7 +19,7 @@
<span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="{{ part|entityURL('create') }}">
<a class="dropdown-item" href="{{ entity_url(part, 'create') }}">
<i class="fas fa-plus-square"></i>
{% trans %}part.create.btn{% endtrans %}
</a>
@ -27,7 +27,7 @@
</div>
{% endif %}
<form method="post" class="mt-2" action="{{ part|entityURL('delete') }}"
<form method="post" class="mt-2" action="{{ entity_url(part, 'delete') }}"
{{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', "submit", "submit") }}
data-delete-title="{% trans with {'%name%': part.name }%}part.delete.confirm_title{% endtrans %}"
data-delete-message="{% trans %}part.delete.message{% endtrans %}">