Allow to view and edit parameters of elements

This commit is contained in:
Jan Böhmer 2023-09-19 11:44:22 +02:00
parent 78a6262665
commit f285061a76
8 changed files with 39 additions and 11 deletions

View file

@ -165,7 +165,7 @@ class Category extends AbstractPartsContainingDBElement
/** @var Collection<int, CategoryParameter>
*/
#[Assert\Valid]
#[Groups(['full', 'category:read'])]
#[Groups(['full', 'category:read', 'category:write'])]
#[ORM\OneToMany(targetEntity: CategoryParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;

View file

@ -119,7 +119,7 @@ class Footprint extends AbstractPartsContainingDBElement
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: FootprintParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
#[Groups(['footprint:read'])]
#[Groups(['footprint:read', 'footprint:write'])]
protected Collection $parameters;
/****************************************

View file

@ -141,7 +141,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: MeasurementUnitParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
#[Groups(['measurement_unit:read'])]
#[Groups(['measurement_unit:read', 'measurement_unit:write'])]
protected Collection $parameters;
/**

View file

@ -73,7 +73,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[ApiResource(
operations: [
new Get(normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read',
'orderdetail:read', 'pricedetail:read', 'attachment:read']], security: 'is_granted("read", object)'),
'orderdetail:read', 'pricedetail:read', 'parameter:read', 'attachment:read'],
'openapi_definition_name' => 'Read',
], security: 'is_granted("read", object)'),
new GetCollection(security: 'is_granted("@parts.read")'),
new Post(securityPostDenormalize: 'is_granted("create", object)'),
new Patch(security: 'is_granted("edit", object)'),
@ -97,7 +99,7 @@ class Part extends AttachmentContainingDBElement
/** @var Collection<int, PartParameter>
*/
#[Assert\Valid]
#[Groups(['full'])]
#[Groups(['full', 'part:read', 'part:write'])]
#[ORM\OneToMany(targetEntity: PartParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;

View file

@ -105,6 +105,7 @@ class StorageLocation extends AbstractPartsContainingDBElement
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: StorageLocationParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
#[Groups(['location:read', 'location:write'])]
protected Collection $parameters;
/**