Improved styling of the BOM edit

This commit is contained in:
Jan Böhmer 2022-12-27 13:03:19 +01:00
parent b83b55b8d4
commit a3ee51e76b
6 changed files with 66 additions and 11 deletions

View file

@ -207,6 +207,10 @@ class ProjectBOMEntry extends AbstractDBElement
$this->quantity = round($this->quantity); $this->quantity = round($this->quantity);
} }
} }
//Non-Part BOM entries are rounded
if ($this->part === null) {
$this->quantity = round($this->quantity);
}
//Check that every part name in the mountnames list is unique (per bom_entry) //Check that every part name in the mountnames list is unique (per bom_entry)
$mountnames = explode(',', $this->mountnames); $mountnames = explode(',', $this->mountnames);

View file

@ -5,6 +5,7 @@ namespace App\Form\ProjectSystem;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Entity\ProjectSystem\ProjectBOMEntry;
use App\Form\Type\PartSelectType; use App\Form\Type\PartSelectType;
use App\Form\Type\RichTextEditorType;
use App\Form\Type\SIUnitType; use App\Form\Type\SIUnitType;
use Svg\Tag\Text; use Svg\Tag\Text;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@ -53,10 +54,14 @@ class ProjectBOMEntryType extends AbstractType
'data-controller' => 'elements--tagsinput', 'data-controller' => 'elements--tagsinput',
] ]
]) ])
->add('comment', TextType::class, [ ->add('comment', RichTextEditorType::class, [
'required' => false, 'required' => false,
'label' => 'project.bom.comment', 'label' => 'project.bom.comment',
'empty_data' => '' 'empty_data' => '',
'mode' => 'markdown-single_line',
'attr' => [
'rows' => 2,
],
]) ])
; ;

View file

@ -25,18 +25,28 @@
{% form_theme form.bom_entries with ['Form/collection_types_layout.html.twig'] %} {% form_theme form.bom_entries with ['Form/collection_types_layout.html.twig'] %}
{% import 'components/collection_type.macro.html.twig' as collection %} {% import 'components/collection_type.macro.html.twig' as collection %}
<div {{ collection.controller(form.bom_entries, 'attachment.edit.delete.confirm') }}> <div {{ collection.controller(form.bom_entries, 'project.bom.delete.confirm') }}>
<table class="table table-striped table-sm" {{ collection.target() }}> <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> <tbody>
{% for attachment in form.bom_entries %} {% for entry in form.bom_entries %}
{{ form_widget(attachment) }} {{ form_widget(entry) }}
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<button type="button" class="btn btn-success" {{ collection.create_btn() }}> <button type="button" class="btn btn-success mb-2" {{ collection.create_btn() }}>
<i class="fas fa-plus-square fa-fw"></i> <i class="fas fa-plus-square fa-fw"></i>
{% trans %}attachment.create{% endtrans %} {% trans %}project.bom.add_entry{% endtrans %}
</button> </button>
</div> </div>
</div> </div>

View file

@ -1,15 +1,39 @@
{% block project_bom_entry_widget %} {% block project_bom_entry_widget %}
{% set target_id = 'expand_row-' ~ random() %}
{% import 'components/collection_type.macro.html.twig' as collection %} {% import 'components/collection_type.macro.html.twig' as collection %}
<tr> <tr>
<td> <td>
{{ form_widget(form) }} <button class="btn btn-sm btn-outline-secondary" type="button" data-bs-toggle="collapse" data-bs-target="#{{ target_id }}">
<i class="fa-solid fa-eye"></i>
</button>
</td>
<td>
{{ form_errors(form.quantity) }}
{{ form_widget(form.quantity) }}
</td>
<td style="min-width: 250px;">
{{ form_errors(form.part) }}
{{ form_widget(form.part) }}
</td>
<td>
{{ form_errors(form.name) }}
{{ form_widget(form.name) }}
</td> </td>
<td> <td>
<button type="button" class="btn btn-danger lot_btn_delete" {{ collection.delete_btn() }}> <button type="button" class="btn btn-danger lot_btn_delete" {{ collection.delete_btn() }}>
<i class="fas fa-trash-alt fa-fw"></i> <i class="fas fa-trash-alt fa-fw"></i>
{% trans %}part_lot.delete{% endtrans %}
</button> </button>
{{ form_errors(form) }} {{ form_errors(form) }}
</td> </td>
</tr> </tr>
<tr class="p-0 d-none"></tr>
<tr class="p-0">
<td colspan="5" class="accordion-body collapse" id="{{ target_id }}">
<div class="">
{{ form_row(form.mountnames) }}
{{ form_row(form.comment) }}
</div>
</td>
</tr>
{% endblock %} {% endblock %}

View file

@ -41,7 +41,7 @@
<div class="input-group {% if sm %}input-group-sm{% endif %}"> <div class="input-group {% if sm %}input-group-sm{% endif %}">
{{ form_widget(form.value) }} {{ form_widget(form.value) }}
{% if form.prefix is defined %} {% if form.prefix is defined %}
{{ form_widget(form.prefix, {'attr': {'class': 'form-select'}}) }} {{ form_widget(form.prefix, {'attr': {'class': '', 'style': 'max-width: 40px;'}}) }}
{% endif %} {% endif %}
{% if unit is not empty %} {% if unit is not empty %}
<label class="input-group-text">{{ unit }}</label> <label class="input-group-text">{{ unit }}</label>

View file

@ -9971,5 +9971,17 @@ Element 3</target>
<target>Notes</target> <target>Notes</target>
</segment> </segment>
</unit> </unit>
<unit id="fR.vNpd" name="project.bom.part">
<segment>
<source>project.bom.part</source>
<target>Part</target>
</segment>
</unit>
<unit id="apnWXEq" name="project.bom.add_entry">
<segment>
<source>project.bom.add_entry</source>
<target>Add entry</target>
</segment>
</unit>
</file> </file>
</xliff> </xliff>