feat(machines) : allow category-only links on machine structure

Enable adding a component, piece, or product to a machine by selecting
only the category (ModelType) without a specific entity. The link
displays a red "À remplir" badge; clicking it reopens the modal
pre-filled with the category so the user can associate an item later.

Backend: entity FKs made nullable on the 3 link tables, modelType FK
added, controller/audit/version/MCP normalization adapted for null
entities.

Frontend: modal accepts category-only confirm, page handles fill mode,
hierarchy builder creates pending nodes, display components show
clickable badge with event propagation through the full hierarchy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 10:15:47 +02:00
parent 342ae37762
commit 1c3b566923
20 changed files with 452 additions and 77 deletions

View File

@@ -47,8 +47,12 @@ class MachinePieceLink
private Machine $machine;
#[ORM\ManyToOne(targetEntity: Piece::class, inversedBy: 'machineLinks')]
#[ORM\JoinColumn(name: 'pieceId', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private Piece $piece;
#[ORM\JoinColumn(name: 'pieceId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
private ?Piece $piece = null;
#[ORM\ManyToOne(targetEntity: ModelType::class)]
#[ORM\JoinColumn(name: 'modelTypeId', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?ModelType $modelType = null;
#[ORM\ManyToOne(targetEntity: MachineComponentLink::class, inversedBy: 'pieceLinks')]
#[ORM\JoinColumn(name: 'parentLinkId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
@@ -98,18 +102,30 @@ class MachinePieceLink
return $this;
}
public function getPiece(): Piece
public function getPiece(): ?Piece
{
return $this->piece;
}
public function setPiece(Piece $piece): static
public function setPiece(?Piece $piece): static
{
$this->piece = $piece;
return $this;
}
public function getModelType(): ?ModelType
{
return $this->modelType;
}
public function setModelType(?ModelType $modelType): static
{
$this->modelType = $modelType;
return $this;
}
public function getParentLink(): ?MachineComponentLink
{
return $this->parentLink;