diff --git a/schemas/index.ts b/schemas/index.ts index 0aecbd0e..7d7825e8 100644 --- a/schemas/index.ts +++ b/schemas/index.ts @@ -4,12 +4,15 @@ import { getListFromMap, getMapFromList } from 'utils'; import regionalSchemas from './regional'; import { appSchemas, coreSchemas, metaSchemas } from './schemas'; import type { + DynamicLinkField, Field, + OptionField, Schema, SchemaMap, SchemaStub, SchemaStubMap, SelectOption, + TargetField, } from './types'; const NAME_FIELD = { @@ -319,16 +322,28 @@ function getFieldMapFromRawCustomFields( label, fieldname, fieldtype, - required: isRequired, section, tab, - target, - options, - references, isCustom: true, - }; + } as Field; - map[parent].push(field as Field); + if (options?.length) { + (field as OptionField).options = options; + } + + if (typeof isRequired === 'number' || typeof isRequired === 'boolean') { + field.required = Boolean(isRequired); + } + + if (typeof target === 'string') { + (field as TargetField).target === 'target'; + } + + if (typeof references === 'string') { + (field as DynamicLinkField).references === 'references'; + } + + map[parent].push(field); return map; }, {} as Record diff --git a/src/utils/sidebarConfig.ts b/src/utils/sidebarConfig.ts index f2527d3f..f720bc1a 100644 --- a/src/utils/sidebarConfig.ts +++ b/src/utils/sidebarConfig.ts @@ -287,7 +287,8 @@ function getCompleteSidebar(): SidebarConfig { { label: t`Customize Form`, name: 'customize-form', - route: `/customize-form`, + // route: `/customize-form`, + route: `/list/CustomForm/${t`Customize Form`}`, hidden: () => !fyo.singles.AccountingSettings?.enableFormCustomization, },