mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-12 21:29:33 +00:00
Projekt BOM-Konfiguration um Assemblies bereinigen.
Assembly BOM-Konfiguration um Projektauswahl erweitern (APS-3, APS-4)
This commit is contained in:
parent
f79dc3a102
commit
df2ce45e4c
53 changed files with 738 additions and 1541 deletions
|
|
@ -25,11 +25,13 @@ namespace App\DataTables;
|
|||
use App\DataTables\Column\EntityColumn;
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\DataTables\Column\MarkdownColumn;
|
||||
use App\DataTables\Helpers\ProjectDataTableHelper;
|
||||
use App\DataTables\Helpers\ColumnSortHelper;
|
||||
use App\DataTables\Helpers\PartDataTableHelper;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\AssemblySystem\AssemblyBOMEntry;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Services\EntityURLGenerator;
|
||||
use App\Services\Formatters\AmountFormatter;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
|
@ -43,12 +45,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
class AssemblyBomEntriesDataTable implements DataTableTypeInterface
|
||||
{
|
||||
public function __construct(
|
||||
protected TranslatorInterface $translator,
|
||||
protected PartDataTableHelper $partDataTableHelper,
|
||||
protected EntityURLGenerator $entityURLGenerator,
|
||||
protected AmountFormatter $amountFormatter,
|
||||
private string $visible_columns,
|
||||
private ColumnSortHelper $csh
|
||||
protected TranslatorInterface $translator,
|
||||
protected PartDataTableHelper $partDataTableHelper,
|
||||
protected ProjectDataTableHelper $projectDataTableHelper,
|
||||
protected EntityURLGenerator $entityURLGenerator,
|
||||
protected AmountFormatter $amountFormatter,
|
||||
private string $visible_columns,
|
||||
private ColumnSortHelper $csh
|
||||
){
|
||||
}
|
||||
|
||||
|
|
@ -86,18 +89,29 @@ class AssemblyBomEntriesDataTable implements DataTableTypeInterface
|
|||
'label' => $this->translator->trans('part.table.name'),
|
||||
'orderField' => 'NATSORT(part.name)',
|
||||
'render' => function ($value, AssemblyBOMEntry $context) {
|
||||
if(!$context->getPart() instanceof Part) {
|
||||
if(!$context->getPart() instanceof Part && !$context->getProject() instanceof Project) {
|
||||
return htmlspecialchars((string) $context->getName());
|
||||
}
|
||||
|
||||
//Part exists if we reach this point
|
||||
if ($context->getPart() !== null) {
|
||||
$tmp = $this->partDataTableHelper->renderName($context->getPart());
|
||||
$tmp = $this->translator->trans('part.table.name.value.for_part', ['%value%' => $tmp]);
|
||||
|
||||
$tmp = $this->partDataTableHelper->renderName($context->getPart());
|
||||
if($context->getName() !== null && $context->getName() !== '') {
|
||||
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
|
||||
if($context->getName() !== null && $context->getName() !== '') {
|
||||
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
|
||||
}
|
||||
} elseif ($context->getProject() !== null) {
|
||||
$tmp = $this->projectDataTableHelper->renderName($context->getProject());
|
||||
$tmp = $this->translator->trans('part.table.name.value.for_project', ['%value%' => $tmp]);
|
||||
|
||||
if($context->getName() !== null && $context->getName() !== '') {
|
||||
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
|
||||
}
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
},
|
||||
|
||||
])
|
||||
->add('ipn', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.ipn'),
|
||||
|
|
|
|||
|
|
@ -23,18 +23,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\DataTables\Helpers;
|
||||
|
||||
use App\Entity\AssemblySystem\Assembly;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Services\EntityURLGenerator;
|
||||
|
||||
/**
|
||||
* A helper service which contains common code to render columns for assembly related tables
|
||||
*/
|
||||
class AssemblyDataTableHelper
|
||||
class ProjectDataTableHelper
|
||||
{
|
||||
public function __construct(private readonly EntityURLGenerator $entityURLGenerator) {
|
||||
}
|
||||
|
||||
public function renderName(Assembly $context): string
|
||||
public function renderName(Project $context): string
|
||||
{
|
||||
$icon = '';
|
||||
|
||||
|
|
@ -25,9 +25,7 @@ namespace App\DataTables;
|
|||
use App\DataTables\Column\EntityColumn;
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\DataTables\Column\MarkdownColumn;
|
||||
use App\DataTables\Helpers\AssemblyDataTableHelper;
|
||||
use App\DataTables\Helpers\PartDataTableHelper;
|
||||
use App\Entity\AssemblySystem\Assembly;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
||||
|
|
@ -46,7 +44,6 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
|||
public function __construct(
|
||||
protected TranslatorInterface $translator,
|
||||
protected PartDataTableHelper $partDataTableHelper,
|
||||
protected AssemblyDataTableHelper $assemblyDataTableHelper,
|
||||
protected EntityURLGenerator $entityURLGenerator,
|
||||
protected AmountFormatter $amountFormatter
|
||||
) {
|
||||
|
|
@ -90,26 +87,16 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
|||
'label' => $this->translator->trans('part.table.name'),
|
||||
'orderField' => 'NATSORT(part.name)',
|
||||
'render' => function ($value, ProjectBOMEntry $context) {
|
||||
if(!$context->getPart() instanceof Part && !$context->getAssembly() instanceof Assembly) {
|
||||
if(!$context->getPart() instanceof Part) {
|
||||
return htmlspecialchars((string) $context->getName());
|
||||
}
|
||||
|
||||
if ($context->getPart() !== null) {
|
||||
$tmp = $this->partDataTableHelper->renderName($context->getPart());
|
||||
$tmp = $this->translator->trans('part.table.name.value.for_part', ['%value%' => $tmp]);
|
||||
//Part exists if we reach this point
|
||||
|
||||
if($context->getName() !== null && $context->getName() !== '') {
|
||||
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
|
||||
}
|
||||
} elseif ($context->getAssembly() !== null) {
|
||||
$tmp = $this->assemblyDataTableHelper->renderName($context->getAssembly());
|
||||
$tmp = $this->translator->trans('part.table.name.value.for_assembly', ['%value%' => $tmp]);
|
||||
|
||||
if($context->getName() !== null && $context->getName() !== '') {
|
||||
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
|
||||
}
|
||||
$tmp = $this->partDataTableHelper->renderName($context->getPart());
|
||||
if($context->getName() !== null && $context->getName() !== '') {
|
||||
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
},
|
||||
])
|
||||
|
|
@ -121,6 +108,8 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
|||
if($context->getPart() instanceof Part) {
|
||||
return $context->getPart()->getIpn();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
])
|
||||
->add('description', MarkdownColumn::class, [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue