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>
This commit is contained in:
fsbrc 2026-01-04 17:01:06 +01:00 committed by GitHub
parent 3e380f82d2
commit 0e61a84ea6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 73 additions and 58 deletions

View file

@ -29,6 +29,7 @@ use App\DataTables\Helpers\PartDataTableHelper;
use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Part;
use App\Entity\ProjectSystem\ProjectBOMEntry;
use App\Services\ElementTypeNameGenerator;
use App\Services\EntityURLGenerator;
use App\Services\Formatters\AmountFormatter;
use Doctrine\ORM\QueryBuilder;
@ -41,7 +42,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class ProjectBomEntriesDataTable implements DataTableTypeInterface
{
public function __construct(protected TranslatorInterface $translator, protected PartDataTableHelper $partDataTableHelper, protected EntityURLGenerator $entityURLGenerator, protected AmountFormatter $amountFormatter)
public function __construct(protected TranslatorInterface $translator, protected PartDataTableHelper $partDataTableHelper,
protected EntityURLGenerator $entityURLGenerator, protected AmountFormatter $amountFormatter, private readonly ElementTypeNameGenerator $elementTypeNameGenerator)
{
}
@ -79,7 +81,14 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
return htmlspecialchars($this->amountFormatter->format($context->getQuantity(), $context->getPart()->getPartUnit()));
},
])
->add('partId', TextColumn::class, [
'label' => $this->translator->trans('project.bom.part_id'),
'visible' => true,
'orderField' => 'part.id',
'render' => function ($value, ProjectBOMEntry $context) {
return $context->getPart() instanceof Part ? (string) $context->getPart()->getId() : '';
},
])
->add('name', TextColumn::class, [
'label' => $this->translator->trans('part.table.name'),
'orderField' => 'NATSORT(part.name)',