mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-01 15:09:35 +00:00
Added ability to view part relations on a part info page
This commit is contained in:
parent
cc2332a83a
commit
7f612bc371
7 changed files with 143 additions and 0 deletions
40
templates/parts/info/_associations.html.twig
Normal file
40
templates/parts/info/_associations.html.twig
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{% import "helper.twig" as helper %}
|
||||
|
||||
{% macro assoc_row(assoc) %}
|
||||
{# @var assoc \App\Entity\Parts\PartAssociation #}
|
||||
<tr>
|
||||
<td>{{ helper.part_icon_link(assoc.owner) }}</td>
|
||||
<td>{{ assoc.typeTranslationKey | trans }}</td>
|
||||
<td>{{ helper.part_icon_link(assoc.other) }}</td>
|
||||
<td>{{ assoc.comment }}</td>
|
||||
</tr>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro assoc_table(assocs, caption) %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover caption-top">
|
||||
<caption>{{ caption | trans }}:</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans %}part_association.table.from{% endtrans %}</th>
|
||||
<th>{% trans %}part_association.table.type{% endtrans %}</th>
|
||||
<th>{% trans %}part_association.table.to{% endtrans %}</th>
|
||||
<th>{% trans %}part_association.edit.comment{% endtrans %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for assoc in assocs %}
|
||||
{{ _self.assoc_row(assoc) }}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% if part.associatedPartsAsOwner is not empty %}
|
||||
{{ _self.assoc_table(part.associatedPartsAsOwner, 'part_association.table.from_this_part') }}
|
||||
{% endif %}
|
||||
|
||||
{% if part.associatedPartsAsOther is not empty %}
|
||||
{{ _self.assoc_table(part.associatedPartsAsOther, 'part_association.table.to_this_part') }}
|
||||
{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue