Assembly Konfiguration in BOM ausblenden, wenn bisher keine Zuordnung zu mindestens einem Eintrag stattgefunden hat (Berücksichtigung Rechtekonfiguration)

This commit is contained in:
Marcel Diegelmann 2025-04-04 10:50:47 +02:00
parent 8c973a3c8d
commit 02460801d9
2 changed files with 38 additions and 3 deletions

View file

@ -0,0 +1,26 @@
<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class AssemblyTwigExtension extends AbstractExtension
{
public function getFunctions(): array
{
return [
new TwigFunction('has_assembly', [$this, 'hasAssembly']),
];
}
public function hasAssembly(array $bomEntries): bool
{
foreach ($bomEntries as $entry) {
if ($entry->getAssembly() !== null) {
return true;
}
}
return false;
}
}

View file

@ -44,9 +44,18 @@
<td style="min-width: 300px;">
{{ form_row(form.part) }}
{{ form_errors(form.part) }}
<div class="text-center mb-2" style="line-height: 1"></div>
{{ form_widget(form.assembly) }}
{{ form_errors(form.assembly) }}
{% if form.vars.value is not null and form.vars.value.project is not null %}
{% set hasAssembly = false %}
{% if is_granted("@assemblies.read") or has_assembly(form.vars.value.project.bomEntries.toArray) %}
<div class="text-center mb-2" style="line-height: 1"></div>
{{ form_widget(form.assembly) }}
{{ form_errors(form.assembly) }}
{% endif %}
{% elseif is_granted("@assemblies.read") %}
{{ form_widget(form.assembly) }}
{{ form_errors(form.assembly) }}
{% endif %}
</td>
<td>
{{ form_widget(form.name) }}