diff --git a/app/components/ComponentItem.vue b/app/components/ComponentItem.vue index 3a6c2bc..1aeca6a 100644 --- a/app/components/ComponentItem.vue +++ b/app/components/ComponentItem.vue @@ -320,13 +320,13 @@ -
+

Sous-composants

{ return Array.isArray(provided) && provided.length ? provided : props.componentModelOptions }) const pieceModelOptionsList = computed(() => props.pieceModelOptionsProvider(props.component) || []) +const childComponents = computed(() => { + const list = props.component.subcomponents || props.component.subComponents || [] + return Array.isArray(list) ? list : [] +}) function fieldKeyFromNameAndType(name, type) { const normalizedName = typeof name === 'string' ? name : '' const normalizedType = typeof type === 'string' ? type : '' diff --git a/app/components/ComponentModelStructureEditor.vue b/app/components/ComponentModelStructureEditor.vue index 3328261..a3a596b 100644 --- a/app/components/ComponentModelStructureEditor.vue +++ b/app/components/ComponentModelStructureEditor.vue @@ -22,6 +22,7 @@ import { } from '~/shared/modelUtils' import { usePieceTypes } from '~/composables/usePieceTypes' import { useComponentTypes } from '~/composables/useComponentTypes' +import type { ComponentModelStructure } from '~/shared/types/inventory' defineOptions({ name: 'ComponentModelStructureEditor' }) @@ -46,7 +47,7 @@ const props = defineProps({ const emit = defineEmits(['update:modelValue']) -const localStructure = reactive(hydrateStructureForEditor(props.modelValue)) +const localStructure = reactive(hydrateStructureForEditor(props.modelValue)) const previousLockedLabel = ref(props.rootTypeLabel || '') const { pieceTypes, loadPieceTypes } = usePieceTypes() @@ -77,9 +78,14 @@ const syncRootType = () => { localStructure.typeComposantId = newTypeId localStructure.typeComposantLabel = newLabel + const match = availableComponentTypes.value.find((type) => type?.id === newTypeId) + if (match?.code) { + localStructure.familyCode = match.code + } + const previousLabel = previousLockedLabel.value - if (!localStructure.name || localStructure.name === previousLabel || localStructure.name === '') { - localStructure.name = newLabel || localStructure.name + if (!localStructure.alias || localStructure.alias === previousLabel || localStructure.alias === '') { + localStructure.alias = newLabel || localStructure.alias } previousLockedLabel.value = newLabel @@ -91,7 +97,12 @@ const syncFromProps = (value: any) => { const hydrated = hydrateStructureForEditor(value) localStructure.customFields = hydrated.customFields localStructure.pieces = hydrated.pieces - localStructure.subComponents = hydrated.subComponents + localStructure.subcomponents = hydrated.subcomponents + localStructure.typeComposantId = hydrated.typeComposantId + localStructure.typeComposantLabel = hydrated.typeComposantLabel + localStructure.modelId = hydrated.modelId + localStructure.familyCode = hydrated.familyCode + localStructure.alias = hydrated.alias lastEmitted = JSON.stringify(cloneStructure(value)) syncRootType() } diff --git a/app/components/MachinePrintSelectionNode.vue b/app/components/MachinePrintSelectionNode.vue index 79a5835..561cafa 100644 --- a/app/components/MachinePrintSelectionNode.vue +++ b/app/components/MachinePrintSelectionNode.vue @@ -58,6 +58,6 @@ const props = defineProps({ selection: { type: Object, required: true } }) -const childComponents = computed(() => props.component.subComponents || []) +const childComponents = computed(() => props.component.subcomponents || props.component.subComponents || []) const childPieces = computed(() => props.component.pieces || []) diff --git a/app/components/ModelStructureViewer.vue b/app/components/ModelStructureViewer.vue index 899593c..d5473dd 100644 --- a/app/components/ModelStructureViewer.vue +++ b/app/components/ModelStructureViewer.vue @@ -3,8 +3,8 @@
{{ stats.customFields }} champ(s) {{ stats.pieces }} pièce(s) - {{ stats.subComponents }} sous-composant(s) - + {{ stats.subcomponents }} sous-composant(s) + Structure vide
diff --git a/app/components/SkeletonComponentNodeSelector.vue b/app/components/SkeletonComponentNodeSelector.vue index 9d087ec..867c317 100644 --- a/app/components/SkeletonComponentNodeSelector.vue +++ b/app/components/SkeletonComponentNodeSelector.vue @@ -5,7 +5,7 @@

- {{ node.name || node.typeComposantLabel || 'Composant' }} + {{ node.alias || node.typeComposantLabel || 'Composant' }}

{{ @@ -46,15 +46,15 @@

-
-
Pièces associées
-
-
- {{ piece.name || piece.typePieceLabel || 'Pièce' }} +
+
Pièces associées
+
+
+ {{ piece.typePieceLabel || 'Pièce' }}

{{ piece.typePieceLabel @@ -95,7 +95,7 @@

Sous-composants
{ }) const hasPieces = computed(() => Array.isArray(props.node?.pieces) && props.node.pieces.length > 0) -const hasSubComponents = computed(() => Array.isArray(props.node?.subComponents) && props.node.subComponents.length > 0) +const hasSubComponents = computed(() => { + const list = props.node?.subcomponents || props.node?.subComponents || [] + return Array.isArray(list) && list.length > 0 +}) const getPieceModels = (typePieceId) => { if (!typePieceId) { diff --git a/app/components/StructureNodeEditor.vue b/app/components/StructureNodeEditor.vue index 417f7cf..9b3892b 100644 --- a/app/components/StructureNodeEditor.vue +++ b/app/components/StructureNodeEditor.vue @@ -28,6 +28,17 @@

{{ node.typeComposantId ? `Sélection : ${getComponentTypeLabel(node.typeComposantId) || 'Inconnue'}` : 'Aucune famille sélectionnée' }}

+
+ + +