diff --git a/Inventory_frontend b/Inventory_frontend index 50d8dde..4a3bcef 160000 --- a/Inventory_frontend +++ b/Inventory_frontend @@ -1 +1 @@ -Subproject commit 50d8dde6d52a96979120421d84f97f1eeba04467 +Subproject commit 4a3bceffa18fcbd7b79fd13e9c5477f115f9a9b6 diff --git a/src/Controller/MachineStructureController.php b/src/Controller/MachineStructureController.php index 6db3556..ed0a909 100644 --- a/src/Controller/MachineStructureController.php +++ b/src/Controller/MachineStructureController.php @@ -709,6 +709,7 @@ class MachineStructureController extends AbstractController 'typeComposant' => $this->normalizeModelType($type), 'productId' => $composant->getProduct()?->getId(), 'product' => $composant->getProduct() ? $this->normalizeProduct($composant->getProduct()) : null, + 'structure' => $this->enrichStructureWithPieceData($composant->getStructure()), 'constructeurs' => $this->normalizeConstructeurs($composant->getConstructeurs()), 'documents' => [], '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 { $type = $piece->getTypePiece();