Fixed issue with removing the bom entries caused by the multiple collapse rows

This commit is contained in:
Jan Böhmer 2022-12-28 23:06:52 +01:00
parent a3ee51e76b
commit 39ed00c7c0
6 changed files with 83 additions and 40 deletions

View file

@ -23,31 +23,6 @@
{% block additional_panes %}
<div class="tab-pane" id="bom">
{% form_theme form.bom_entries with ['Form/collection_types_layout.html.twig'] %}
{% import 'components/collection_type.macro.html.twig' as collection %}
<div {{ collection.controller(form.bom_entries, 'project.bom.delete.confirm') }}>
<table class="table table-striped table-bordered table-sm" {{ collection.target() }}>
<thead>
<tr>
<th></th> {# expand button #}
<th>{% trans %}project.bom.quantity{% endtrans %}</th>
<th>{% trans %}project.bom.part{% endtrans %}</th>
<th>{% trans %}project.bom.name{% endtrans %}</th>
<th></th> {# Remove button #}
</tr>
</thead>
<tbody>
{% for entry in form.bom_entries %}
{{ form_widget(entry) }}
{% endfor %}
</tbody>
</table>
<button type="button" class="btn btn-success mb-2" {{ collection.create_btn() }}>
<i class="fas fa-plus-square fa-fw"></i>
{% trans %}project.bom.add_entry{% endtrans %}
</button>
</div>
{{ form_widget(form.bom_entries) }}
</div>
{% endblock %}

View file

@ -1,3 +1,32 @@
{% block project_bom_entry_collection_widget %}
{% import 'components/collection_type.macro.html.twig' as collection %}
<div {{ collection.controller(form, 'project.bom.delete.confirm', 3) }}>
<table class="table table-striped table-bordered table-sm" {{ collection.target() }}>
<thead>
<tr>
<th></th> {# expand button #}
<th>{% trans %}project.bom.quantity{% endtrans %}</th>
<th>{% trans %}project.bom.part{% endtrans %}</th>
<th>{% trans %}project.bom.name{% endtrans %}</th>
<th></th> {# Remove button #}
</tr>
</thead>
<tbody>
{% for entry in form %}
{{ form_widget(entry) }}
{% endfor %}
</tbody>
</table>
<button type="button" class="btn btn-success mb-2" {{ collection.create_btn() }}>
<i class="fas fa-plus-square fa-fw"></i>
{% trans %}project.bom.add_entry{% endtrans %}
</button>
</div>
{% endblock %}
{% block project_bom_entry_widget %}
{% set target_id = 'expand_row-' ~ random() %}

View file

@ -1,12 +1,14 @@
{% macro controller(form, deleteMessage) %}
{% macro controller(form, deleteMessage, rowsToDelete) %}
{% if form.vars.prototype is defined %}
{{ stimulus_controller('elements/collection_type', {
'deleteMessage': deleteMessage|trans,
'prototype': form_widget(form.vars.prototype)|e('html_attr')
'prototype': form_widget(form.vars.prototype)|e('html_attr'),
'rowsToDelete': rowsToDelete,
}) }}
{% else %} {# If add_element is disabled/forbidden, prototype is not available #}
{{ stimulus_controller('elements/collection_type', {
'deleteMessage': deleteMessage|trans,
'rowsToDelete': rowsToDelete
}) }}
{% endif %}
{% endmacro %}