From a8cabbab562ce0de16a0e081cff0246df72cc59e Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Thu, 24 Nov 2022 09:40:45 +0800 Subject: [PATCH] fix: x-collection-field (#1134) --- .../core/client/src/schema-initializer/utils.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/core/client/src/schema-initializer/utils.ts b/packages/core/client/src/schema-initializer/utils.ts index 2554e13a1d..70cfd6081f 100644 --- a/packages/core/client/src/schema-initializer/utils.ts +++ b/packages/core/client/src/schema-initializer/utils.ts @@ -73,7 +73,7 @@ export const findTableColumn = (schema: Schema, key: string, action: string, dee }; export const useTableColumnInitializerFields = () => { - const { currentFields = [] } = useCollection(); + const { name, currentFields = [] } = useCollection(); const { getInterface } = useCollectionManager(); return currentFields .filter((field) => field?.interface && field?.interface !== 'subTable' && !field?.isForeignKey) @@ -81,7 +81,7 @@ export const useTableColumnInitializerFields = () => { const interfaceConfig = getInterface(field.interface); const schema = { name: field.name, - 'x-collection-field': `${field.name}`, + 'x-collection-field': `${name}.${field.name}`, 'x-component': 'CollectionField', 'x-read-pretty': true, 'x-component-props': {}, @@ -168,7 +168,7 @@ export const useInheritsTableColumnInitializerFields = () => { name: `${k.name}`, 'x-component': 'CollectionField', 'x-read-pretty': true, - 'x-collection-field': `${k.name}`, + 'x-collection-field': `${name}.${k.name}`, 'x-component-props': {}, }; return { @@ -206,7 +206,7 @@ export const useFormItemInitializerFields = (options?: any) => { 'x-designer': 'FormItem.Designer', 'x-component': field.interface === 'o2m' ? 'TableField' : 'CollectionField', 'x-decorator': 'FormItem', - 'x-collection-field': `${field.name}`, + 'x-collection-field': `${name}.${field.name}`, 'x-component-props': {}, 'x-read-pretty': field?.uiSchema?.['x-read-pretty'], }; @@ -297,7 +297,7 @@ export const useInheritsFormItemInitializerFields = (options?) => { 'x-designer': 'FormItem.Designer', 'x-component': field.interface === 'o2m' ? 'TableField' : 'CollectionField', 'x-decorator': 'FormItem', - 'x-collection-field': `${field.name}`, + 'x-collection-field': `${name}.${field.name}`, 'x-component-props': {}, 'x-read-pretty': field?.uiSchema?.['x-read-pretty'], }; @@ -334,7 +334,7 @@ export const useCustomFormItemInitializerFields = (options?: any) => { 'x-designer': 'FormItem.Designer', 'x-component': 'AssignedField', 'x-decorator': 'FormItem', - 'x-collection-field': `${field.name}`, + 'x-collection-field': `${name}.${field.name}`, }; return { type: 'item', @@ -368,7 +368,7 @@ export const useCustomBulkEditFormItemInitializerFields = (options?: any) => { 'x-designer': 'FormItem.Designer', 'x-component': 'BulkEditField', 'x-decorator': 'FormItem', - 'x-collection-field': `${field.name}`, + 'x-collection-field': `${name}.${field.name}`, }; return { type: 'item', @@ -419,7 +419,6 @@ export const useCurrentSchema = (action: string, key: string, find = findSchema, } const { remove } = useDesignable(); const schema = find(fieldSchema, key, action); - console.log(fieldSchema, key, action); return { schema, exists: !!schema,