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:
2026-04-03 13:13:36 +02:00
parent a88e4a68fb
commit 7da78b3b3e
3 changed files with 12 additions and 1 deletions

View File

@@ -141,6 +141,7 @@ export const normalizeStructureForSave = (input: any): any => {
const value: Record<string, any> = { const value: Record<string, any> = {
type: field.type, type: field.type,
required: !!field.required, required: !!field.required,
machineContextOnly: !!field.machineContextOnly,
} }
if (field.options && field.options.length) { if (field.options && field.options.length) {
value.options = field.options value.options = field.options

View File

@@ -78,10 +78,18 @@ export const hydrateCustomFields = (fields: any[]): any[] => {
const customFieldId = typeof field?.customFieldId === 'string' ? field.customFieldId : undefined const customFieldId = typeof field?.customFieldId === 'string' ? field.customFieldId : undefined
const orderIndex = typeof field?.orderIndex === 'number' ? field.orderIndex : index 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 { return {
name, name,
type, type,
required, required,
machineContextOnly,
options, options,
optionsText, optionsText,
defaultValue, defaultValue,
@@ -153,6 +161,7 @@ export const mapComponentCustomFields = (fields: any[]) => {
name: typeof field?.name === 'string' ? field.name : '', name: typeof field?.name === 'string' ? field.name : '',
type: field?.type ?? 'text', type: field?.type ?? 'text',
required: !!field?.required, required: !!field?.required,
machineContextOnly: !!field?.machineContextOnly,
options: Array.isArray(field?.options) ? field.options : [], options: Array.isArray(field?.options) ? field.options : [],
optionsText: typeof field?.optionsText === 'string' ? field.optionsText : '', optionsText: typeof field?.optionsText === 'string' ? field.optionsText : '',
defaultValue, defaultValue,

View File

@@ -82,7 +82,7 @@ const sanitizePieceCustomFields = (fields: any[]): PieceModelCustomField[] => {
options = parsed.length > 0 ? parsed : undefined options = parsed.length > 0 ? parsed : undefined
} }
const result: PieceModelCustomField = { name, type, required } const result: PieceModelCustomField = { name, type, required, machineContextOnly: !!field?.machineContextOnly }
if (options) { if (options) {
result.options = options result.options = options
} }
@@ -131,6 +131,7 @@ const hydratePieceCustomFields = (fields: any[]): PieceModelStructureEditorField
name: field?.name ?? '', name: field?.name ?? '',
type: field?.type ?? 'text', type: field?.type ?? 'text',
required: !!field?.required, required: !!field?.required,
machineContextOnly: !!field?.machineContextOnly,
options: Array.isArray(field?.options) ? field.options : undefined, options: Array.isArray(field?.options) ? field.options : undefined,
optionsText: typeof field?.optionsText === 'string' optionsText: typeof field?.optionsText === 'string'
? field.optionsText ? field.optionsText