feat(ui): streamline skeleton model selection and toast display
This commit is contained in:
@@ -1090,6 +1090,7 @@ const normalizePieceNode = (source, context = {}) => {
|
||||
}
|
||||
|
||||
const normalizeComponentNode = (source, context = {}) => {
|
||||
const isRoot = context.isRoot ?? false
|
||||
const typeComposantId = source?.typeComposantId
|
||||
|| source?.typeComposant?.id
|
||||
|| context.typeComposantId
|
||||
@@ -1110,10 +1111,10 @@ const normalizeComponentNode = (source, context = {}) => {
|
||||
?? context.componentModelId
|
||||
?? null,
|
||||
__requirementId: source?.__requirementId ?? context.requirementId ?? null,
|
||||
customFields: Array.isArray(source?.customFields)
|
||||
customFields: isRoot && Array.isArray(source?.customFields)
|
||||
? cloneStructure(source.customFields)
|
||||
: [],
|
||||
pieces: Array.isArray(source?.pieces)
|
||||
pieces: isRoot && Array.isArray(source?.pieces)
|
||||
? source.pieces.map((piece) => normalizePieceNode(piece))
|
||||
: [],
|
||||
subComponents: Array.isArray(source?.subComponents || source?.sousComposants)
|
||||
@@ -1127,6 +1128,8 @@ const normalizeComponentNode = (source, context = {}) => {
|
||||
?? sub?.composantModelId
|
||||
?? sub?.composantModel?.id
|
||||
?? null,
|
||||
requirementId: sub?.__requirementId ?? null,
|
||||
isRoot: false,
|
||||
}))
|
||||
: [],
|
||||
}
|
||||
@@ -1173,6 +1176,7 @@ const createEmptyComponentDefinition = (requirement) => {
|
||||
},
|
||||
{
|
||||
requirementId: requirement?.id || null,
|
||||
isRoot: true,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1188,6 +1192,7 @@ const createDefinitionFromModel = (model, requirement) => {
|
||||
const definition = normalizeComponentNode(structure, {
|
||||
requirementId: requirement?.id || null,
|
||||
componentModelId: model?.id || null,
|
||||
isRoot: true,
|
||||
})
|
||||
definition.__componentModelId = model?.id || null
|
||||
return definition
|
||||
@@ -1206,6 +1211,7 @@ const buildDefinitionFromComponent = (component, requirement) => {
|
||||
typeComposantLabel: requirement?.typeComposant?.name
|
||||
|| component?.typeComposant?.name
|
||||
|| '',
|
||||
isRoot: true,
|
||||
})
|
||||
return definition
|
||||
}
|
||||
@@ -1224,7 +1230,7 @@ const applyDefinitionToNode = (target, definition) => {
|
||||
? definition.pieces.map((piece) => normalizePieceNode(piece))
|
||||
: []
|
||||
target.subComponents = Array.isArray(definition.subComponents)
|
||||
? definition.subComponents.map((sub) => normalizeComponentNode(sub))
|
||||
? definition.subComponents.map((sub) => normalizeComponentNode(sub, { isRoot: false }))
|
||||
: []
|
||||
}
|
||||
|
||||
@@ -1255,6 +1261,7 @@ const handleNodeComponentModelChange = async (node, typeComposantId, modelId) =>
|
||||
await ensureModelsForNodeDefinition(node)
|
||||
} else {
|
||||
node.__componentModelId = null
|
||||
node.customFields = []
|
||||
node.pieces = []
|
||||
node.subComponents = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user