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:
Matthieu
2026-03-05 17:25:23 +01:00
parent 6f1bac381d
commit 32d03b480d
49 changed files with 1058 additions and 6093 deletions

View File

@@ -4,7 +4,6 @@ export const RELATION_ID_MAP: Record<string, { key: string; path: string }> = {
composantId: { key: 'composant', path: 'composants' },
pieceId: { key: 'piece', path: 'pieces' },
productId: { key: 'product', path: 'products' },
typeMachineId: { key: 'typeMachine', path: 'type_machines' },
typeComposantId: { key: 'typeComposant', path: 'model_types' },
typePieceId: { key: 'typePiece', path: 'model_types' },
typeProductId: { key: 'typeProduct', path: 'model_types' },

View File

@@ -60,9 +60,8 @@ export const uniqueConstructeurIds = (...sources: unknown[]): string[] => {
if (value.constructeur) {
explore(value.constructeur);
}
// Only extract ID if this looks like a constructeur object (has @type or recognizable fields)
// Don't extract ID from component/piece/product objects that happen to be passed in
if (typeof value.id === 'string' && !value.name && !value.typeComposant && !value.typePiece && !value.typeProduct) {
// Extract ID from constructeur-like objects, but skip component/piece/product entities
if (typeof value.id === 'string' && !value.typeComposant && !value.typePiece && !value.typeProduct) {
pushId(value.id);
}
return;

View File

@@ -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)

View File

@@ -208,11 +208,6 @@ export const getProductDisplay = (
((source.requirement as AnyRecord)?.structure as AnyRecord)?.products,
((source.requirement as AnyRecord)?.structure as AnyRecord)?.productSkeleton,
((source.requirement as AnyRecord)?.componentSkeleton as AnyRecord)?.products,
(source.typeMachineComponentRequirement as AnyRecord)?.products,
(source.typeMachineComponentRequirement as AnyRecord)?.productSkeleton,
((source.typeMachineComponentRequirement as AnyRecord)?.structure as AnyRecord)?.products,
((source.typeMachineComponentRequirement as AnyRecord)?.structure as AnyRecord)?.productSkeleton,
((source.typeMachineComponentRequirement as AnyRecord)?.componentSkeleton as AnyRecord)?.products,
(source.typeComposant as AnyRecord)?.products,
(source.typeComposant as AnyRecord)?.productSkeleton,
((source.typeComposant as AnyRecord)?.structure as AnyRecord)?.products,