Restore component catalog with requirement-based instantiation
This commit is contained in:
@@ -783,6 +783,7 @@ import { useApi } from '~/composables/useApi'
|
||||
import { useToast } from '~/composables/useToast'
|
||||
import { useDocuments } from '~/composables/useDocuments'
|
||||
import { getFileIcon } from '~/utils/fileIcons'
|
||||
import { sanitizeDefinitionOverrides } from '~/shared/modelUtils'
|
||||
import { canPreviewDocument } from '~/utils/documentPreview'
|
||||
import ComponentHierarchy from '~/components/ComponentHierarchy.vue'
|
||||
import DocumentUpload from '~/components/DocumentUpload.vue'
|
||||
@@ -976,41 +977,6 @@ const createPieceSelectionEntry = (requirement, source = null) => ({
|
||||
},
|
||||
})
|
||||
|
||||
const sanitizeDefinitionOverrides = (definition) => {
|
||||
if (!definition || typeof definition !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
const payload = {}
|
||||
|
||||
if (typeof definition.name === 'string') {
|
||||
const name = definition.name.trim()
|
||||
if (name.length > 0) {
|
||||
payload.name = name
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof definition.reference === 'string') {
|
||||
const reference = definition.reference.trim()
|
||||
if (reference.length > 0) {
|
||||
payload.reference = reference
|
||||
}
|
||||
}
|
||||
|
||||
if (definition.constructeurId !== undefined && definition.constructeurId !== null && definition.constructeurId !== '') {
|
||||
payload.constructeurId = definition.constructeurId
|
||||
}
|
||||
|
||||
if (definition.prix !== undefined && definition.prix !== null && definition.prix !== '') {
|
||||
const parsed = Number(definition.prix)
|
||||
if (!Number.isNaN(parsed)) {
|
||||
payload.prix = parsed
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(payload).length ? payload : null
|
||||
}
|
||||
|
||||
const resetSkeletonRequirementSelections = () => {
|
||||
Object.keys(componentRequirementSelections).forEach((key) => {
|
||||
delete componentRequirementSelections[key]
|
||||
|
||||
Reference in New Issue
Block a user