mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-04 18:25:04 +02:00
Refactored TwigExtensions Part 1
This commit is contained in:
parent
8e6300079a
commit
b078389381
21 changed files with 301 additions and 89 deletions
|
@ -1,4 +1,4 @@
|
|||
<form method="post" class="" action="{{ entity|entityURL('delete') }}" {{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', "submit", "submit") }}
|
||||
<form method="post" class="" action="{{ entity_url(entity, 'delete') }}" {{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', "submit", "submit") }}
|
||||
data-delete-title="{% trans with {'%name%': entity.name }%}entity.delete.confirm_title{% endtrans %}"
|
||||
data-delete-message="{% trans %}entity.delete.message{% endtrans %}">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="row mb-2">
|
||||
<div class="offset-3 col">
|
||||
<a class="btn btn-info {% if not is_granted('create', entity) %}disabled{% endif %}" href="{{ entity | entityURL('clone') }}">{% trans %}entity.duplicate{% endtrans %}</a>
|
||||
<a class="btn btn-info {% if not is_granted('create', entity) %}disabled{% endif %}" href="{{ entity_url(entity, 'clone') }}">{% trans %}entity.duplicate{% endtrans %}</a>
|
||||
</div>
|
||||
</div>
|
|
@ -60,7 +60,7 @@
|
|||
<div class="col-sm-9">
|
||||
<span class="form-control-plaintext">{{ profile.name ?? '-' }}
|
||||
{% if profile %}
|
||||
<a href="{{ profile | entityURL('edit') }}" title="{% trans %}label_generator.edit_profile{% endtrans %}"
|
||||
<a href="{{ entity_url(profile, 'edit') }}" title="{% trans %}label_generator.edit_profile{% endtrans %}"
|
||||
><i class="fas fa-edit"></i></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
|
|
|
@ -143,11 +143,11 @@
|
|||
{% if attach.secure and not is_granted('show_private', attach) %}
|
||||
{# Leave blank #}
|
||||
{% elseif attach.picture %}
|
||||
<a href="{{ attach | entityURL('file_view') }}" rel="noopener" target="_blank" data-turbo="false">
|
||||
<a href="{{ entity_url(attach, 'file_view') }}" rel="noopener" target="_blank" data-turbo="false">
|
||||
<img class="img-fluid img-thumbnail thumbnail-sm" src="{{ attachment_thumbnail(attach, 'thumbnail_md') }}" alt="{% trans %}attachment.preview.alt{% endtrans %}" />
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ attach | entityURL('file_view') }}" rel="noopener" target="_blank" data-turbo="false" class="link-external">{% trans %}attachment.view{% endtrans %}</a>
|
||||
<a href="{{ entity_url(attach, 'file_view') }}" rel="noopener" target="_blank" data-turbo="false" class="link-external">{% trans %}attachment.view{% endtrans %}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<br><br>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{% block card_title %}
|
||||
<i class="fas fa-edit fa-fw" aria-hidden="true"></i>
|
||||
{% trans with {'%name%': part.name} %}part.edit.card_title{% endtrans %}
|
||||
<b><a href="{{ part|entityURL('info') }}" class="text-white">{{ part.name }}</a></b>
|
||||
<b><a href="{{ entity_url(part, 'info') }}" class="text-white">{{ part.name }}</a></b>
|
||||
<div class="float-end">
|
||||
{% trans %}id.label{% endtrans %}: {{ part.id }}
|
||||
</div>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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 %}">
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
|
||||
{# Retain the query parameters of the search form if it is existing #}
|
||||
{% if searchFilter is defined %}
|
||||
{% for property, value in searchFilter|toArray %}
|
||||
{% for property, value in searchFilter|to_array %}
|
||||
<input type="hidden" name="{{ property }}" data-no-clear="true" value="{{ value }}">
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="accordion-header">
|
||||
<button class="accordion-button collapsed py-2" data-bs-toggle="collapse" data-bs-target="#entityInfo">
|
||||
{% if entity.masterPictureAttachment is not null and attachment_manager.isFileExisting(entity.masterPictureAttachment) %}
|
||||
<img class="hoverpic ms-0 me-1 d-inline" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ entity.masterPictureAttachment | entityURL('file_view') }}" src="{{ attachment_thumbnail(entity.masterPictureAttachment, 'thumbnail_sm') }}">
|
||||
<img class="hoverpic ms-0 me-1 d-inline" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ entity_url(entity.masterPictureAttachment, 'file_view') }}" src="{{ attachment_thumbnail(entity.masterPictureAttachment, 'thumbnail_sm') }}">
|
||||
{% else %}
|
||||
{{ helper.entity_icon(entity, "me-1") }}
|
||||
{% endif %}
|
||||
|
@ -71,7 +71,7 @@
|
|||
<div class="col-sm-3">
|
||||
{% block quick_links %}{% endblock %}
|
||||
|
||||
<a class="btn btn-secondary w-100 mb-2" href="{{ entity | entityURL('edit') }}">
|
||||
<a class="btn btn-secondary w-100 mb-2" href="{{ entity_url(entity, 'edit') }}">
|
||||
<i class="fas fa-edit"></i> {% trans %}entity.edit.btn{% endtrans %}
|
||||
</a>
|
||||
<div class="">
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
{% set disabled = attachment.secure and not is_granted("show_secure", attachment) %}
|
||||
{% if not attachment_helper or attachment_helper.fileExisting(attachment) %}
|
||||
{% if link and not disabled %}
|
||||
<a target="_blank" data-turbo="false" rel="noopener" href="{{ attachment|entityURL('file_view') }}">
|
||||
<a target="_blank" data-turbo="false" rel="noopener" href="{{ entity_url(attachment, 'file_view') }}">
|
||||
{% endif %}
|
||||
{% if attachment.picture %}
|
||||
<img class="hoverpic" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ attachment|entityURL('file_view') }}" src="{{ attachment|entityURL('file_view') }}">
|
||||
<img class="hoverpic" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ entity_url(attachment, 'file_view') }}" src="{{ entity_url(attachment, 'file_view') }}">
|
||||
{% else %}
|
||||
<i class="text-dark {{ class }} {{ ext_to_fa_icon(attachment.extension) }}"></i>
|
||||
{% endif %}
|
||||
|
@ -59,7 +59,7 @@
|
|||
{% for e in entity.pathArray %}
|
||||
<li>
|
||||
{% if link_type is not empty and e.id is not null %}
|
||||
<a href="{{ e | entityURL(link_type) }}">{{ e.name }}</a>
|
||||
<a href="{{ entity_url(e, link_type) }}">{{ e.name }}</a>
|
||||
{% else %}
|
||||
{{ e.name }}
|
||||
{% endif %}
|
||||
|
@ -115,7 +115,7 @@
|
|||
{% for e in entity.pathArray %}
|
||||
<li class="breadcrumb-item {% if loop.last %}active{% endif %}">
|
||||
{% if link_type is not empty and not loop.last and e.id is not null %}
|
||||
<a href="{{ e | entityURL(link_type) }}">{{ e.name }}</a>
|
||||
<a href="{{ entity_url(e, link_type) }}">{{ e.name }}</a>
|
||||
{% else %}
|
||||
{{ e.name }}
|
||||
{% endif %}
|
||||
|
@ -141,9 +141,9 @@
|
|||
{% endif %}
|
||||
{% if is_granted('show_users', entity) %}
|
||||
{% if lastModified == true %}
|
||||
{% set user = getLastEditingUser(entity) %}
|
||||
{% set user = last_editing_user(entity) %}
|
||||
{% else %}
|
||||
{% set user = getCreatingUser(entity) %}
|
||||
{% set user = creating_user(entity) %}
|
||||
{% endif %}
|
||||
|
||||
{% if user is not null %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue