diff --git a/frontend/app/components/PieceItem.vue b/frontend/app/components/PieceItem.vue index a081d6a..6007b39 100644 --- a/frontend/app/components/PieceItem.vue +++ b/frontend/app/components/PieceItem.vue @@ -14,7 +14,7 @@ /> -
+
-

+

{{ pieceData.name }} + — manquant { const edits = slotEdits.pieces[slot.slotId] + const selectedPieceId = edits && 'selectedPieceId' in edits ? edits.selectedPieceId : (slot.selectedPieceId ?? null) return { slotId: slot.slotId, typePieceId: slot.typePieceId, - selectedPieceId: edits && 'selectedPieceId' in edits ? edits.selectedPieceId : (slot.selectedPieceId ?? null), + selectedPieceId, selectedPieceName: slot.selectedPieceName ?? null, quantity: edits && 'quantity' in edits ? edits.quantity! : (slot.quantity ?? 1), position: slot.position ?? i, label: pieceTypeLabelMap.value[slot.typePieceId] || `Pièce #${i + 1}`, + isEmpty: !selectedPieceId, } }) }) @@ -305,14 +307,16 @@ export function useComponentEdit(componentId: string) { if (!structure?.products) return [] return (structure.products as any[]).map((slot: any, i: number) => { const edits = slotEdits.products[slot.slotId] + const selectedProductId = edits && 'selectedProductId' in edits ? edits.selectedProductId : (slot.selectedProductId ?? null) return { slotId: slot.slotId, typeProductId: slot.typeProductId, - selectedProductId: edits && 'selectedProductId' in edits ? edits.selectedProductId : (slot.selectedProductId ?? null), + selectedProductId, selectedProductName: slot.selectedProductName ?? null, familyCode: slot.familyCode, position: slot.position ?? i, label: productTypeLabelMap.value[slot.typeProductId] || `Produit #${i + 1}`, + isEmpty: !selectedProductId, } }) }) @@ -322,15 +326,17 @@ export function useComponentEdit(componentId: string) { if (!structure?.subcomponents) return [] return (structure.subcomponents as any[]).map((slot: any, i: number) => { const edits = slotEdits.subcomponents[slot.slotId] + const selectedComponentId = edits && 'selectedComposantId' in edits ? edits.selectedComposantId : (slot.selectedComponentId ?? null) return { slotId: slot.slotId, typeComposantId: slot.typeComposantId, - selectedComponentId: edits && 'selectedComposantId' in edits ? edits.selectedComposantId : (slot.selectedComponentId ?? null), + selectedComponentId, selectedComponentName: slot.selectedComponentName ?? null, alias: slot.alias, familyCode: slot.familyCode, position: slot.position ?? i, label: slot.alias || `Sous-composant #${i + 1}`, + isEmpty: !selectedComponentId, } }) }) diff --git a/frontend/app/composables/useMachineHierarchy.ts b/frontend/app/composables/useMachineHierarchy.ts index b46c6cb..441d1be 100644 --- a/frontend/app/composables/useMachineHierarchy.ts +++ b/frontend/app/composables/useMachineHierarchy.ts @@ -227,11 +227,13 @@ export const buildMachineHierarchyFromLinks = ( const definition = (def.definition && typeof def.definition === 'object' ? def.definition : def) as AnyRecord const resolved = (def.resolvedPiece && typeof def.resolvedPiece === 'object' ? def.resolvedPiece : null) as AnyRecord | null const quantity = typeof definition.quantity === 'number' ? definition.quantity : (typeof def.quantity === 'number' ? def.quantity : 1) + const isEmpty = !resolved + const typePieceName = (resolved?.typePiece as AnyRecord)?.name || (definition.typePiece as AnyRecord)?.name || (def.typePiece as AnyRecord)?.name || null return { ...(resolved || {}), id: resolved?.id || `structure-piece-${composantId}-${index}`, pieceId: resolved?.id || null, - name: resolved?.name || definition.role || definition.name || def.role || def.name || `Pièce ${index + 1}`, + name: resolved?.name || definition.role || definition.name || def.role || def.name || (typePieceName ? `${typePieceName}` : `Pièce ${index + 1}`), reference: resolved?.reference || definition.reference || def.reference || null, prix: resolved?.prix ?? null, constructeurs: resolved?.constructeurs || [], @@ -243,6 +245,7 @@ export const buildMachineHierarchyFromLinks = ( parentComponentLinkId: machineComponentLinkId, parentComponentName: componentName, _structurePiece: true, + _emptySlot: isEmpty, } }) as AnyRecord[] diff --git a/frontend/app/pages/component/[id]/edit.vue b/frontend/app/pages/component/[id]/edit.vue index 8e2d591..8cb830c 100644 --- a/frontend/app/pages/component/[id]/edit.vue +++ b/frontend/app/pages/component/[id]/edit.vue @@ -195,7 +195,7 @@ class="form-control" >
@@ -231,7 +231,7 @@ class="form-control" > -
- {{ slot.selectedPieceName || '— Non sélectionné' }} - x{{ slot.quantity }} +
+ +
@@ -272,7 +275,7 @@ class="form-control" > -
- {{ slot.selectedProductName || '— Non sélectionné' }} +
+ +
@@ -298,7 +302,7 @@ class="form-control" > -
- {{ slot.selectedComponentName || '— Non sélectionné' }} +
+ +

diff --git a/frontend/app/pages/piece/[id].vue b/frontend/app/pages/piece/[id].vue index d1851ff..46a7da9 100644 --- a/frontend/app/pages/piece/[id].vue +++ b/frontend/app/pages/piece/[id].vue @@ -224,7 +224,7 @@ class="form-control" > @@ -244,10 +244,11 @@ class="form-control" > -
- {{ productSelectionLabels[index] || '— Non sélectionné' }} +
+ +
diff --git a/src/Controller/MachineStructureController.php b/src/Controller/MachineStructureController.php index 30e4b9e..edfdd9e 100644 --- a/src/Controller/MachineStructureController.php +++ b/src/Controller/MachineStructureController.php @@ -728,6 +728,7 @@ class MachineStructureController extends AbstractController $pieceData = [ 'slotId' => $slot->getId(), 'typePieceId' => $slot->getTypePiece()?->getId(), + 'typePiece' => $this->normalizeModelType($slot->getTypePiece()), 'quantity' => $slot->getQuantity(), 'selectedPieceId' => $slot->getSelectedPiece()?->getId(), ];