From 93ad5d6a9a3f15833ec5e10079a7649178539140 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Wed, 9 Aug 2023 10:26:45 +0530 Subject: [PATCH] incr: use common form for now - fix custom field type --- schemas/index.ts | 27 +++++++++++++++++++++------ src/utils/sidebarConfig.ts | 3 ++- 2 files changed, 23 insertions(+), 7 deletions(-) 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, },