Show mount names as comma separated tags

This commit is contained in:
Jan Böhmer 2022-12-23 12:38:49 +01:00
parent b074095038
commit b1ed52bcc3
3 changed files with 20 additions and 2 deletions

View file

@ -132,7 +132,15 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
])
->add('mountnames', TextColumn::class, [
'label' => 'project.bom.mountnames',
'render' => function ($value, ProjectBOMEntry $context) {
$html = '';
foreach (explode(',', $context->getMountnames()) as $mountname) {
$html .= sprintf('<span class="badge badge-secondary bg-secondary">%s</span> ', htmlspecialchars($mountname));
}
return $html;
},
])

View file

@ -1,4 +1,5 @@
{% import "components/attachments.macro.html.twig" as attachments %}
{% import "helper.twig" as helper %}
<table class="table table-striped table-sm table-hover table-responsive-sm">
<thead>
@ -13,12 +14,15 @@
<tbody>
{% for bom_entry in part.projectBomEntries %}
{# @var bom_entry App\Entity\Project\ProjectBOMEntry #}
<tr>
<td>{% if bom_entry.project.masterPictureAttachment is not null %}{{ attachments.attachment_icon(bom_entry.project.masterPictureAttachment, attachment_manager) }}{% endif %}</td>
<td><a href="{{ url('project_info', {'id': bom_entry.project.iD}) }}">{{ bom_entry.project.name }}</a></td> {# Name #}
<td>{{ bom_entry.project.description|format_markdown }}</td> {# Description #}
<td>{{ bom_entry.quantity | format_amount(part.partUnit) }}</td>
<td>{{ bom_entry.mountnames }}</td>
<td>{% for tag in bom_entry.mountnames|split(',') %}
<span class="badge bg-secondary badge-secondary" >{{ tag | trim }}</span>
{% endfor %}</td>
</tr>
{% endfor %}

View file

@ -9953,5 +9953,11 @@ Element 3</target>
<target>BOM Qty.</target>
</segment>
</unit>
<unit id="gqYIO6x" name="project.bom.mountnames">
<segment>
<source>project.bom.mountnames</source>
<target>Mount names</target>
</segment>
</unit>
</file>
</xliff>