refactor(machines) : remove TypeMachine skeleton system, simplify machine creation
- Remove TypeEdit*, TypeInfoDisplay, MachineSkeletonSummary, MachineCreatePreview components - Remove machine-skeleton pages and type pages - Remove useMachineTypesApi, useMachineSkeletonEditor, useMachineCreateSelections composables - Add AddEntityToMachineModal for direct entity linking - Update machine detail/create pages for direct custom fields - Fix SearchSelect, category display, and ipartial search filters Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -123,7 +123,8 @@ export function extractStructureCustomFields(structure: any): any[] {
|
||||
|
||||
export function deduplicateFieldDefinitions(definitions: any[]): any[] {
|
||||
const result: any[] = []
|
||||
const seen = new Set<string>()
|
||||
const seenIds = new Set<string>()
|
||||
const seenNames = new Set<string>()
|
||||
|
||||
const orderedDefinitions = (Array.isArray(definitions) ? definitions.slice() : [])
|
||||
.sort((a, b) => resolveOrderIndex(a) - resolveOrderIndex(b))
|
||||
@@ -132,9 +133,12 @@ export function deduplicateFieldDefinitions(definitions: any[]): any[] {
|
||||
if (!field || typeof field !== 'object') return
|
||||
const id = field.id ?? field.customFieldId ?? field.customField?.id ?? null
|
||||
const nameKey = fieldKeyFromNameAndType(field.name, field.type)
|
||||
const key = id || nameKey
|
||||
if (key && seen.has(key)) return
|
||||
if (key) seen.add(key)
|
||||
// Deduplicate by name+type (primary) AND by id — a field with the same
|
||||
// name+type is the same field even when stored with different IDs.
|
||||
if (nameKey && seenNames.has(nameKey)) return
|
||||
if (id && seenIds.has(id)) return
|
||||
if (id) seenIds.add(id)
|
||||
if (nameKey) seenNames.add(nameKey)
|
||||
field.orderIndex = resolveOrderIndex(field)
|
||||
result.push(field)
|
||||
})
|
||||
@@ -219,7 +223,8 @@ export function dedupeMergedFields(fields: any[]): any[] {
|
||||
: []
|
||||
}
|
||||
|
||||
const seen = new Map<string, any>()
|
||||
const seenById = new Map<string, any>()
|
||||
const seenByName = new Map<string, any>()
|
||||
const result: any[] = []
|
||||
|
||||
const orderedFields = fields.slice().sort((a, b) => resolveOrderIndex(a) - resolveOrderIndex(b))
|
||||
@@ -236,18 +241,14 @@ export function dedupeMergedFields(fields: any[]): any[] {
|
||||
|
||||
const fieldId = resolveCustomFieldId(field)
|
||||
const nameKey = fieldKeyFromNameAndType(normalizedName, field.type)
|
||||
const key = fieldId || nameKey
|
||||
|
||||
if (!key) {
|
||||
field.orderIndex = resolveOrderIndex(field)
|
||||
result.push(field)
|
||||
return
|
||||
}
|
||||
// Check duplicates by name+type first (same field can have different IDs)
|
||||
const existing = (nameKey ? seenByName.get(nameKey) : undefined) ?? (fieldId ? seenById.get(fieldId) : undefined)
|
||||
|
||||
const existing = seen.get(key)
|
||||
if (!existing) {
|
||||
field.orderIndex = resolveOrderIndex(field)
|
||||
seen.set(key, field)
|
||||
if (fieldId) seenById.set(fieldId, field)
|
||||
if (nameKey) seenByName.set(nameKey, field)
|
||||
result.push(field)
|
||||
return
|
||||
}
|
||||
@@ -258,7 +259,8 @@ export function dedupeMergedFields(fields: any[]): any[] {
|
||||
if (!existingHasValue && incomingHasValue) {
|
||||
Object.assign(existing, field)
|
||||
existing.orderIndex = Math.min(resolveOrderIndex(existing), resolveOrderIndex(field))
|
||||
seen.set(key, existing)
|
||||
if (fieldId) seenById.set(fieldId, existing)
|
||||
if (nameKey) seenByName.set(nameKey, existing)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -276,45 +278,29 @@ export function buildDefinitionSources(entity: any, entityType: 'composant' | 'p
|
||||
}
|
||||
|
||||
if (entityType === 'composant') {
|
||||
const requirement = entity.typeMachineComponentRequirement || {}
|
||||
const type = requirement.typeComposant || entity.typeComposant || {}
|
||||
const type = entity.typeComposant || {}
|
||||
|
||||
pushFields(entity.customFields)
|
||||
pushFields(entity.definition?.customFields)
|
||||
pushFields(type.customFields)
|
||||
pushFields(requirement.customFields)
|
||||
pushFields(requirement.definition?.customFields)
|
||||
|
||||
;[
|
||||
entity.definition?.structure,
|
||||
type.structure,
|
||||
type.componentSkeleton,
|
||||
requirement.structure,
|
||||
requirement.componentSkeleton,
|
||||
].forEach((structure) => {
|
||||
const fields = extractStructureCustomFields(structure)
|
||||
if (fields.length) definitions.push(...fields)
|
||||
})
|
||||
} else {
|
||||
const requirement = entity.typeMachinePieceRequirement || {}
|
||||
const type = requirement.typePiece || entity.typePiece || {}
|
||||
const type = entity.typePiece || {}
|
||||
|
||||
pushFields(entity.customFields)
|
||||
pushFields(entity.definition?.customFields)
|
||||
pushFields(entity.typePiece?.customFields)
|
||||
pushFields(type.customFields)
|
||||
pushFields(requirement.typePiece?.customFields)
|
||||
pushFields(requirement.customFields)
|
||||
pushFields(requirement.definition?.customFields)
|
||||
|
||||
;[
|
||||
entity.definition?.structure,
|
||||
entity.typePiece?.structure,
|
||||
type.structure,
|
||||
type.pieceSkeleton,
|
||||
entity.typePiece?.pieceSkeleton,
|
||||
requirement.structure,
|
||||
requirement.pieceSkeleton,
|
||||
].forEach((structure) => {
|
||||
const fields = extractStructureCustomFields(structure)
|
||||
if (fields.length) definitions.push(...fields)
|
||||
|
||||
Reference in New Issue
Block a user