diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index a97762b1..7c205d1f 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -39,6 +39,7 @@ use App\DataTables\Filters\PartSearchFilter; use App\DataTables\Helpers\ColumnSortHelper; use App\DataTables\Helpers\PartDataTableHelper; use App\Doctrine\Helpers\FieldHelper; +use App\Entity\AssemblySystem\Assembly; use App\Entity\Parts\ManufacturingStatus; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; @@ -240,6 +241,34 @@ final class PartsDataTable implements DataTableTypeInterface ]); } + //Add a assembly column to list where the part is used, when the user has the permission to see the assemblies + if ($this->security->isGranted('read', Assembly::class)) { + $this->csh->add('assemblies', TextColumn::class, [ + 'label' => $this->translator->trans('assembly.labelp'), + 'render' => function ($value, Part $context): string { + //Only show the first 5 assembly names + $assemblies = $context->getAssemblies(); + $tmp = ""; + + $max = 5; + + for ($i = 0; $i < min($max, count($assemblies)); $i++) { + $url = $this->urlGenerator->infoURL($assemblies[$i]); + $tmp .= sprintf('%s', $url, htmlspecialchars($assemblies[$i]->getName())); + if ($i < count($assemblies) - 1) { + $tmp .= ", "; + } + } + + if (count($assemblies) > $max) { + $tmp .= ", + ".(count($assemblies) - $max); + } + + return $tmp; + } + ]); + } + $this->csh ->add('edit', IconLinkColumn::class, [ 'label' => $this->translator->trans('part.table.edit'), diff --git a/templates/parts/info/_assemblies.html.twig b/templates/parts/info/_assemblies.html.twig new file mode 100644 index 00000000..d4996c59 --- /dev/null +++ b/templates/parts/info/_assemblies.html.twig @@ -0,0 +1,31 @@ +{% import "components/attachments.macro.html.twig" as attachments %} +{% import "helper.twig" as helper %} + + + + + + + + + + + + + {% for bom_entry in part.assemblyBomEntries %} + {# @var bom_entry App\Entity\Assembly\AssemblyBOMEntry #} + + + {# Name #} + {# Description #} + + + {% endfor %} + +
{% trans %}entity.info.name{% endtrans %}{% trans %}description.label{% endtrans %}{% trans %}assembly.bom.quantity{% endtrans %}
{% if bom_entry.assembly.masterPictureAttachment is not null %}{{ attachments.attachment_icon(bom_entry.assembly.masterPictureAttachment, attachment_manager) }}{% endif %}{{ bom_entry.assembly.name }}{{ bom_entry.assembly.description|format_markdown }}{{ bom_entry.quantity | format_amount(part.partUnit) }}
+ + + + {% trans %}part.info.add_part_to_assembly{% endtrans %} + \ No newline at end of file diff --git a/templates/parts/info/show_part_info.html.twig b/templates/parts/info/show_part_info.html.twig index 96b5e209..cd7b4ce7 100644 --- a/templates/parts/info/show_part_info.html.twig +++ b/templates/parts/info/show_part_info.html.twig @@ -109,15 +109,20 @@ {% trans %}vendor.partinfo.history{% endtrans %} - {% if part.projectBomEntries is not empty %} - - {% endif %} + +