mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-13 21:59:34 +00:00
Part-Übersicht sowie -Detailansicht um Assembly Information erweitern
This commit is contained in:
parent
a47f6c22e6
commit
7e8d444ac8
16 changed files with 156 additions and 9 deletions
|
|
@ -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('<a href="%s">%s</a>', $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'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue