Skip to content

Commit 0e61a84

Browse files
fsbrcjbtronics
andauthored
Allow to view part ID in project BOM
* added feature of part-id in project bom view * Made part id column label translatable --------- Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
1 parent 3e380f8 commit 0e61a84

2 files changed

Lines changed: 73 additions & 58 deletions

File tree

src/DataTables/ProjectBomEntriesDataTable.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use App\Entity\Attachments\Attachment;
3030
use App\Entity\Parts\Part;
3131
use App\Entity\ProjectSystem\ProjectBOMEntry;
32+
use App\Services\ElementTypeNameGenerator;
3233
use App\Services\EntityURLGenerator;
3334
use App\Services\Formatters\AmountFormatter;
3435
use Doctrine\ORM\QueryBuilder;
@@ -41,7 +42,8 @@
4142

4243
class ProjectBomEntriesDataTable implements DataTableTypeInterface
4344
{
44-
public function __construct(protected TranslatorInterface $translator, protected PartDataTableHelper $partDataTableHelper, protected EntityURLGenerator $entityURLGenerator, protected AmountFormatter $amountFormatter)
45+
public function __construct(protected TranslatorInterface $translator, protected PartDataTableHelper $partDataTableHelper,
46+
protected EntityURLGenerator $entityURLGenerator, protected AmountFormatter $amountFormatter, private readonly ElementTypeNameGenerator $elementTypeNameGenerator)
4547
{
4648
}
4749

@@ -79,7 +81,14 @@ public function configure(DataTable $dataTable, array $options): void
7981
return htmlspecialchars($this->amountFormatter->format($context->getQuantity(), $context->getPart()->getPartUnit()));
8082
},
8183
])
82-
84+
->add('partId', TextColumn::class, [
85+
'label' => $this->translator->trans('project.bom.part_id'),
86+
'visible' => true,
87+
'orderField' => 'part.id',
88+
'render' => function ($value, ProjectBOMEntry $context) {
89+
return $context->getPart() instanceof Part ? (string) $context->getPart()->getId() : '';
90+
},
91+
])
8392
->add('name', TextColumn::class, [
8493
'label' => $this->translator->trans('part.table.name'),
8594
'orderField' => 'NATSORT(part.name)',

0 commit comments

Comments
 (0)