fix(modeles): normaliser structure et champs perso
This commit is contained in:
@@ -403,6 +403,7 @@ import { useComposants } from '~/composables/useComposants'
|
||||
import { useCustomFields } from '~/composables/useCustomFields'
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import { useToast } from '~/composables/useToast'
|
||||
import { extractRelationId } from '~/shared/apiRelations'
|
||||
import { useDocuments } from '~/composables/useDocuments'
|
||||
import { useConstructeurs } from '~/composables/useConstructeurs'
|
||||
import { formatStructurePreview, normalizeStructureForEditor } from '~/shared/modelUtils'
|
||||
@@ -435,7 +436,7 @@ const { get } = useApi()
|
||||
const { componentTypes, loadComponentTypes } = useComponentTypes()
|
||||
const { updateComposant } = useComposants()
|
||||
const { ensureConstructeurs } = useConstructeurs()
|
||||
const { upsertCustomFieldValue, updateCustomFieldValue } = useCustomFields()
|
||||
const { upsertCustomFieldValue, updateCustomFieldValue, getCustomFieldValuesByEntity } = useCustomFields()
|
||||
const toast = useToast()
|
||||
const { loadDocumentsByComponent, uploadDocuments, deleteDocument } = useDocuments()
|
||||
|
||||
@@ -636,6 +637,11 @@ const fetchComponent = async () => {
|
||||
if (result.success) {
|
||||
component.value = result.data
|
||||
componentDocuments.value = Array.isArray(result.data?.documents) ? result.data.documents : []
|
||||
|
||||
const customValues = await getCustomFieldValuesByEntity('composant', result.data.id)
|
||||
if (customValues.success && Array.isArray(customValues.data)) {
|
||||
component.value.customFieldValues = customValues.data
|
||||
}
|
||||
} else {
|
||||
component.value = null
|
||||
componentDocuments.value = []
|
||||
@@ -651,7 +657,13 @@ watch(
|
||||
return
|
||||
}
|
||||
|
||||
selectedTypeId.value = currentComponent.typeComposantId || ''
|
||||
const resolvedTypeId = currentComponent.typeComposantId
|
||||
|| extractRelationId(currentComponent.typeComposant)
|
||||
|| ''
|
||||
if (resolvedTypeId && !currentComponent.typeComposantId) {
|
||||
currentComponent.typeComposantId = resolvedTypeId
|
||||
}
|
||||
selectedTypeId.value = resolvedTypeId
|
||||
|
||||
editionForm.name = currentComponent.name || ''
|
||||
editionForm.reference = currentComponent.reference || ''
|
||||
|
||||
Reference in New Issue
Block a user