fix(custom-fields) : preserve CustomField ID in piece structure payload
Prevents data loss when saving ModelType: the frontend now sends existing CustomField IDs so the backend can match them instead of deleting and recreating. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -158,6 +158,13 @@ const buildPayload = (
|
|||||||
orderIndex: index,
|
orderIndex: index,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.id) {
|
||||||
|
payload.id = field.id
|
||||||
|
}
|
||||||
|
if (field.customFieldId) {
|
||||||
|
payload.customFieldId = field.customFieldId
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'select') {
|
if (type === 'select') {
|
||||||
const options = normalizeLineEndings(field.optionsText)
|
const options = normalizeLineEndings(field.optionsText)
|
||||||
.split('\n')
|
.split('\n')
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ const hydratePieceCustomFields = (fields: any[]): PieceModelStructureEditorField
|
|||||||
? field.options.join('\n')
|
? field.options.join('\n')
|
||||||
: '',
|
: '',
|
||||||
orderIndex: typeof field?.orderIndex === 'number' ? field.orderIndex : index,
|
orderIndex: typeof field?.orderIndex === 'number' ? field.orderIndex : index,
|
||||||
|
...(field?.id ? { id: field.id } : {}),
|
||||||
|
...(field?.customFieldId ? { customFieldId: field.customFieldId } : {}),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ export interface PieceModelCustomField {
|
|||||||
key?: string
|
key?: string
|
||||||
value?: unknown
|
value?: unknown
|
||||||
defaultValue?: string | null
|
defaultValue?: string | null
|
||||||
|
id?: string
|
||||||
|
customFieldId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PieceModelProduct {
|
export interface PieceModelProduct {
|
||||||
|
|||||||
Reference in New Issue
Block a user