mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
47 lines
No EOL
2.5 KiB
Twig
47 lines
No EOL
2.5 KiB
Twig
{# Renders a editable list of all attachments. form is the Attachment CollectionType #}
|
|
{% macro attachment_edit_list(form, part_mode = false) %}
|
|
{% form_theme form with ['parts/edit/edit_form_styles.html.twig'] %}
|
|
|
|
{% import 'components/collection_type.macro.html.twig' as collection %}
|
|
<div {{ collection.controller(form, 'attachment.edit.delete.confirm') }}>
|
|
<table class="table table-striped table-sm" {{ collection.target() }}>
|
|
<tbody>
|
|
{% for attachment in form %}
|
|
{{ form_widget(attachment) }}
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="mb-2">
|
|
<button type="button" class="btn btn-success" {{ collection.create_btn() }} {% if part_mode and not is_granted('edit', part) %}disabled{% endif %}>
|
|
<i class="fas fa-plus-square fa-fw"></i>
|
|
{% trans %}attachment.create{% endtrans %}
|
|
</button>
|
|
|
|
<button type="button" class="btn btn-outline-success" {{ stimulus_action('elements/collection_type', 'uploadMultipleFiles') }} {% if part_mode and not is_granted('edit', part) %}disabled{% endif %}>
|
|
<i class="fas fa-upload fa-fw"></i>
|
|
{% trans %}attachment.upload_multiple_files{% endtrans %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-2x hoverpic", link = true) %}
|
|
{# @var App\Entity\Attachments\Attachment attachment #}
|
|
{% set disabled = attachment.secure and not is_granted("show_private", 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-title="{{ attachment.name }}" 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 %} |