mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-11 20:59:36 +00:00
Assembly Konfiguration in BOM ausblenden, wenn bisher keine Zuordnung zu mindestens einem Eintrag stattgefunden hat (Berücksichtigung Rechtekonfiguration)
This commit is contained in:
parent
8c973a3c8d
commit
02460801d9
2 changed files with 38 additions and 3 deletions
26
src/Twig/AssemblyTwigExtension.php
Normal file
26
src/Twig/AssemblyTwigExtension.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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) }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue