mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-17 00:01:32 +02:00
Moved attachment_icon logic to attachment.macro.html.twig
This commit is contained in:
parent
a01ed3acf6
commit
9adebc35c5
3 changed files with 21 additions and 22 deletions
|
@ -1,5 +1,3 @@
|
||||||
{% import "helper.twig" as helper %}
|
|
||||||
|
|
||||||
<table class="table table-striped table-sm table-hover table-responsive-sm">
|
<table class="table table-striped table-sm table-hover table-responsive-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -18,7 +16,8 @@
|
||||||
{% for attachment in part.attachments %}
|
{% for attachment in part.attachments %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ helper.attachment_icon(attachment, attachment_manager) }}
|
{% import "components/attachments.macro.html.twig" as attachments %}
|
||||||
|
{{ attachments.attachment_icon(attachment, attachment_manager) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">{{ attachment.name }}</td>
|
<td class="align-middle">{{ attachment.name }}</td>
|
||||||
<td class="align-middle">{{ attachment.attachmentType.fullPath }}</td>
|
<td class="align-middle">{{ attachment.attachmentType.fullPath }}</td>
|
||||||
|
|
|
@ -17,4 +17,23 @@
|
||||||
{% trans %}attachment.create{% endtrans %}
|
{% trans %}attachment.create{% endtrans %}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-3x", link = true) %}
|
||||||
|
{% 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="{{ entity_url(attachment, 'file_view') }}">
|
||||||
|
{% endif %}
|
||||||
|
{% if attachment.picture %}
|
||||||
|
<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 %}
|
||||||
|
{% if link and not disabled %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% elseif not attachment_helper.fileExisting(attachment) %}
|
||||||
|
<i class="{{ class }} fa-exclamation-triangle text-danger" title="{% trans %}attachment.file_not_found{% endtrans %}"></i>
|
||||||
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
|
@ -6,25 +6,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-3x", link = true) %}
|
|
||||||
{% 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="{{ entity_url(attachment, 'file_view') }}">
|
|
||||||
{% endif %}
|
|
||||||
{% if attachment.picture %}
|
|
||||||
<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 %}
|
|
||||||
{% if link and not disabled %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% elseif not attachment_helper.fileExisting(attachment) %}
|
|
||||||
<i class="{{ class }} fa-exclamation-triangle text-danger" title="{% trans %}attachment.file_not_found{% endtrans %}"></i>
|
|
||||||
{% endif %}
|
|
||||||
{% endmacro %}
|
|
||||||
|
|
||||||
{% macro string_to_tags(string, class="badge bg-info") %}
|
{% macro string_to_tags(string, class="badge bg-info") %}
|
||||||
{% for tag in string|split(',') %}
|
{% for tag in string|split(',') %}
|
||||||
<a href="{{ path('part_list_tags', {'tag': tag | trim | url_encode}) }}" class="{{ class }}" >{{ tag | trim }}</a>
|
<a href="{{ path('part_list_tags', {'tag': tag | trim | url_encode}) }}" class="{{ class }}" >{{ tag | trim }}</a>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue