feat(machine) : exposer structure composant + pièces résolues dans la vue machine
- normalizeComposant : inclure structure du composant dans la réponse - enrichStructureWithPieceData : résoudre selectedPieceId vers les données complètes de la pièce catalogue (nom, référence, prix, etc.) - Update submodule : affichage pièces incluses + quantité machine Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Submodule Inventory_frontend updated: 50d8dde6d5...4a3bceffa1
@@ -709,6 +709,7 @@ class MachineStructureController extends AbstractController
|
|||||||
'typeComposant' => $this->normalizeModelType($type),
|
'typeComposant' => $this->normalizeModelType($type),
|
||||||
'productId' => $composant->getProduct()?->getId(),
|
'productId' => $composant->getProduct()?->getId(),
|
||||||
'product' => $composant->getProduct() ? $this->normalizeProduct($composant->getProduct()) : null,
|
'product' => $composant->getProduct() ? $this->normalizeProduct($composant->getProduct()) : null,
|
||||||
|
'structure' => $this->enrichStructureWithPieceData($composant->getStructure()),
|
||||||
'constructeurs' => $this->normalizeConstructeurs($composant->getConstructeurs()),
|
'constructeurs' => $this->normalizeConstructeurs($composant->getConstructeurs()),
|
||||||
'documents' => [],
|
'documents' => [],
|
||||||
'customFields' => $type ? $this->normalizeCustomFieldDefinitions($type->getComponentCustomFields()) : [],
|
'customFields' => $type ? $this->normalizeCustomFieldDefinitions($type->getComponentCustomFields()) : [],
|
||||||
@@ -716,6 +717,28 @@ class MachineStructureController extends AbstractController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function enrichStructureWithPieceData(?array $structure): ?array
|
||||||
|
{
|
||||||
|
if (!is_array($structure) || !isset($structure['pieces']) || !is_array($structure['pieces'])) {
|
||||||
|
return $structure;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($structure['pieces'] as &$entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$selectedId = $entry['selectedPieceId'] ?? null;
|
||||||
|
if ($selectedId) {
|
||||||
|
$piece = $this->pieceRepository->find($selectedId);
|
||||||
|
if ($piece instanceof Piece) {
|
||||||
|
$entry['resolvedPiece'] = $this->normalizePiece($piece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $structure;
|
||||||
|
}
|
||||||
|
|
||||||
private function normalizePiece(Piece $piece): array
|
private function normalizePiece(Piece $piece): array
|
||||||
{
|
{
|
||||||
$type = $piece->getTypePiece();
|
$type = $piece->getTypePiece();
|
||||||
|
|||||||
Reference in New Issue
Block a user