Implement attachment CollectionType using stimulus

This commit is contained in:
Jan Böhmer 2022-08-03 20:28:27 +02:00
parent bf3dba0fb2
commit 8323f374a4
10 changed files with 141 additions and 231 deletions

View file

@ -0,0 +1,20 @@
{# 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>
<button type="button" class="btn btn-success" {{ collection.create_btn() }} {% if part_mode and not is_granted('attachments.create', part) %}disabled{% endif %}>
<i class="fas fa-plus-square fa-fw"></i>
{% trans %}attachment.create{% endtrans %}
</button>
</div>
{% endmacro %}

View file

@ -1,6 +1,6 @@
{% macro controller(form, deleteMessage) %}
{{ stimulus_controller('elements/collection_type', {
'deleteMessage': 'parameter.delete.confirm'|trans,
'deleteMessage': deleteMessage|trans,
'prototype': form_widget(form.vars.prototype)|e('html_attr')
}) }}
{% endmacro %}