fix(custom-fields) : pass machineContextOnly through structure serialize/hydrate
- componentStructure: include machineContextOnly in save payload value object - componentStructureHydrate: read machineContextOnly in hydrate and mapComponentCustomFields - pieceProductStructure: include machineContextOnly in sanitize and hydrate Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,7 @@ export const normalizeStructureForSave = (input: any): any => {
|
||||
const value: Record<string, any> = {
|
||||
type: field.type,
|
||||
required: !!field.required,
|
||||
machineContextOnly: !!field.machineContextOnly,
|
||||
}
|
||||
if (field.options && field.options.length) {
|
||||
value.options = field.options
|
||||
|
||||
@@ -78,10 +78,18 @@ export const hydrateCustomFields = (fields: any[]): any[] => {
|
||||
const customFieldId = typeof field?.customFieldId === 'string' ? field.customFieldId : undefined
|
||||
const orderIndex = typeof field?.orderIndex === 'number' ? field.orderIndex : index
|
||||
|
||||
const machineContextOnly =
|
||||
typeof field?.machineContextOnly === 'boolean'
|
||||
? field.machineContextOnly
|
||||
: typeof valueObject?.machineContextOnly === 'boolean'
|
||||
? valueObject.machineContextOnly
|
||||
: false
|
||||
|
||||
return {
|
||||
name,
|
||||
type,
|
||||
required,
|
||||
machineContextOnly,
|
||||
options,
|
||||
optionsText,
|
||||
defaultValue,
|
||||
@@ -153,6 +161,7 @@ export const mapComponentCustomFields = (fields: any[]) => {
|
||||
name: typeof field?.name === 'string' ? field.name : '',
|
||||
type: field?.type ?? 'text',
|
||||
required: !!field?.required,
|
||||
machineContextOnly: !!field?.machineContextOnly,
|
||||
options: Array.isArray(field?.options) ? field.options : [],
|
||||
optionsText: typeof field?.optionsText === 'string' ? field.optionsText : '',
|
||||
defaultValue,
|
||||
|
||||
@@ -82,7 +82,7 @@ const sanitizePieceCustomFields = (fields: any[]): PieceModelCustomField[] => {
|
||||
options = parsed.length > 0 ? parsed : undefined
|
||||
}
|
||||
|
||||
const result: PieceModelCustomField = { name, type, required }
|
||||
const result: PieceModelCustomField = { name, type, required, machineContextOnly: !!field?.machineContextOnly }
|
||||
if (options) {
|
||||
result.options = options
|
||||
}
|
||||
@@ -131,6 +131,7 @@ const hydratePieceCustomFields = (fields: any[]): PieceModelStructureEditorField
|
||||
name: field?.name ?? '',
|
||||
type: field?.type ?? 'text',
|
||||
required: !!field?.required,
|
||||
machineContextOnly: !!field?.machineContextOnly,
|
||||
options: Array.isArray(field?.options) ? field.options : undefined,
|
||||
optionsText: typeof field?.optionsText === 'string'
|
||||
? field.optionsText
|
||||
|
||||
Reference in New Issue
Block a user