From b4d950566c183b058204c889290733a2e10f1793 Mon Sep 17 00:00:00 2001 From: dream2023 <1098626505@qq.com> Date: Thu, 18 Jan 2024 18:41:15 +0800 Subject: [PATCH] fix: bug --- .../items/CreateFormBlockInitializer.tsx | 2 ++ .../items/RecordAssociationBlockInitializer.tsx | 1 + .../RecordAssociationDetailsBlockInitializer.tsx | 1 + .../items/RecordAssociationFormBlockInitializer.tsx | 13 +++++++++---- .../RecordAssociationGridCardBlockInitializer.tsx | 1 + .../items/RecordAssociationListBlockInitializer.tsx | 1 + .../items/RecordFormBlockInitializer.tsx | 2 ++ ...ordReadPrettyAssociationFormBlockInitializer.tsx | 12 +++++++++--- .../items/RecordReadPrettyFormBlockInitializer.tsx | 2 ++ .../items/TableSelectorInitializer.tsx | 1 + 10 files changed, 29 insertions(+), 7 deletions(-) diff --git a/packages/core/client/src/schema-initializer/items/CreateFormBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/CreateFormBlockInitializer.tsx index 32fabd3374..af4b3b8b47 100644 --- a/packages/core/client/src/schema-initializer/items/CreateFormBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/CreateFormBlockInitializer.tsx @@ -26,6 +26,7 @@ export const CreateFormBlockInitializer = () => { const blockSchema = createFormBlockSchema({ actionInitializers: 'CreateFormActionInitializers', association, + namespace: collection.namespace, collection: collection.name, template: s, }); @@ -41,6 +42,7 @@ export const CreateFormBlockInitializer = () => { createFormBlockSchema({ actionInitializers: 'CreateFormActionInitializers', association, + namespace: collection.namespace, collection: collection.name, }), ); diff --git a/packages/core/client/src/schema-initializer/items/RecordAssociationBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordAssociationBlockInitializer.tsx index c3f771ddf1..bce64c87f0 100644 --- a/packages/core/client/src/schema-initializer/items/RecordAssociationBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordAssociationBlockInitializer.tsx @@ -28,6 +28,7 @@ export const RecordAssociationBlockInitializer = () => { createTableBlockSchema({ rowKey: collection.filterTargetKey, collection: field.target, + namespace: collection.namespace, resource, association: resource, }), diff --git a/packages/core/client/src/schema-initializer/items/RecordAssociationDetailsBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordAssociationDetailsBlockInitializer.tsx index 5e66b5d5ee..49b5c55dbf 100644 --- a/packages/core/client/src/schema-initializer/items/RecordAssociationDetailsBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordAssociationDetailsBlockInitializer.tsx @@ -28,6 +28,7 @@ export const RecordAssociationDetailsBlockInitializer = () => { createDetailsBlockSchema({ collection: field.target, resource, + namespace: collection.namespace, association: resource, rowKey: collection.filterTargetKey || 'id', }), diff --git a/packages/core/client/src/schema-initializer/items/RecordAssociationFormBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordAssociationFormBlockInitializer.tsx index ed6bb4d519..75fd100695 100644 --- a/packages/core/client/src/schema-initializer/items/RecordAssociationFormBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordAssociationFormBlockInitializer.tsx @@ -1,17 +1,20 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { FormOutlined } from '@ant-design/icons'; import { useSchemaTemplateManager } from '../../schema-templates'; import { createFormBlockSchema, useRecordCollectionDataSourceItems } from '../utils'; import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '../../application'; +import { useCollectionManager } from '../../collection-manager'; export const RecordAssociationFormBlockInitializer = () => { const itemConfig = useSchemaInitializerItem(); const { onCreateBlockSchema, componentType, createBlockSchema, ...others } = itemConfig; const { insert } = useSchemaInitializer(); + const { getCollection } = useCollectionManager(); const { getTemplateSchemaByMode } = useSchemaTemplateManager(); const field = itemConfig.field; - const collection = field.target; + const collectionName = field.target; + const collection = useMemo(() => getCollection(collectionName), [collectionName]); const resource = `${field.collectionName}.${field.name}`; return ( { const s = await getTemplateSchemaByMode(item); if (item.template.componentName === 'FormItem') { const blockSchema = createFormBlockSchema({ - collection, + collection: collectionName, + namespace: collection.namespace, resource, association: resource, action, @@ -46,8 +50,9 @@ export const RecordAssociationFormBlockInitializer = () => { } else { insert( createFormBlockSchema({ - collection, + collection: collectionName, resource, + namespace: collection.namespace, association: resource, action, useSourceId: '{{ useSourceIdFromParentRecord }}', diff --git a/packages/core/client/src/schema-initializer/items/RecordAssociationGridCardBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordAssociationGridCardBlockInitializer.tsx index e0f7f53beb..21e85b97b8 100644 --- a/packages/core/client/src/schema-initializer/items/RecordAssociationGridCardBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordAssociationGridCardBlockInitializer.tsx @@ -30,6 +30,7 @@ export const RecordAssociationGridCardBlockInitializer = () => { rowKey: collection.filterTargetKey, collection: field.target, resource, + namespace: collection.namespace, association: resource, }), ); diff --git a/packages/core/client/src/schema-initializer/items/RecordAssociationListBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordAssociationListBlockInitializer.tsx index dabb0a2e1d..dbcdd3e50b 100644 --- a/packages/core/client/src/schema-initializer/items/RecordAssociationListBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordAssociationListBlockInitializer.tsx @@ -30,6 +30,7 @@ export const RecordAssociationListBlockInitializer = () => { rowKey: collection.filterTargetKey, collection: field.target, resource, + namespace: collection.namespace, association: resource, }), ); diff --git a/packages/core/client/src/schema-initializer/items/RecordFormBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordFormBlockInitializer.tsx index decfe41730..b72d3264af 100644 --- a/packages/core/client/src/schema-initializer/items/RecordFormBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordFormBlockInitializer.tsx @@ -25,6 +25,7 @@ export const RecordFormBlockInitializer = () => { const blockSchema = createFormBlockSchema({ association, collection: collection.name, + namespace: collection.namespace, action: 'get', useSourceId: '{{ useSourceIdFromParentRecord }}', useParams: '{{ useParamsFromRecord }}', @@ -43,6 +44,7 @@ export const RecordFormBlockInitializer = () => { createFormBlockSchema({ association, collection: collection.name, + namespace: collection.namespace, action: 'get', useSourceId: '{{ useSourceIdFromParentRecord }}', useParams: '{{ useParamsFromRecord }}', diff --git a/packages/core/client/src/schema-initializer/items/RecordReadPrettyAssociationFormBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordReadPrettyAssociationFormBlockInitializer.tsx index 3a92bd8722..7ce6c31f0e 100644 --- a/packages/core/client/src/schema-initializer/items/RecordReadPrettyAssociationFormBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordReadPrettyAssociationFormBlockInitializer.tsx @@ -5,15 +5,19 @@ import { useBlockRequestContext } from '../../block-provider'; import { useSchemaTemplateManager } from '../../schema-templates'; import { createReadPrettyFormBlockSchema, useRecordCollectionDataSourceItems } from '../utils'; import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '../../application'; +import { useCollectionManager } from '../../collection-manager'; export const RecordReadPrettyAssociationFormBlockInitializer = () => { const itemConfig = useSchemaInitializerItem(); const { onCreateBlockSchema, componentType, createBlockSchema, ...others } = itemConfig; const { insert } = useSchemaInitializer(); + const { getCollection } = useCollectionManager(); const { getTemplateSchemaByMode } = useSchemaTemplateManager(); const field = itemConfig.field; - const collection = field.target; + const collectionName = field.target; + const collection = getCollection(collectionName); + const resource = `${field.collectionName}.${field.name}`; const { block } = useBlockRequestContext(); const actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null; @@ -28,7 +32,8 @@ export const RecordReadPrettyAssociationFormBlockInitializer = () => { if (item.template.componentName === 'ReadPrettyFormItem') { const blockSchema = createReadPrettyFormBlockSchema({ actionInitializers, - collection, + collection: collectionName, + namespace: collection.namespace, resource, association: resource, action: 'get', @@ -47,9 +52,10 @@ export const RecordReadPrettyAssociationFormBlockInitializer = () => { insert( createReadPrettyFormBlockSchema({ actionInitializers, - collection, + collection: collectionName, resource, association: resource, + namespace: collection.namespace, action: 'get', useSourceId: '{{ useSourceIdFromParentRecord }}', useParams: '{{ useParamsFromRecord }}', diff --git a/packages/core/client/src/schema-initializer/items/RecordReadPrettyFormBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/RecordReadPrettyFormBlockInitializer.tsx index 67889efb95..94381c3218 100644 --- a/packages/core/client/src/schema-initializer/items/RecordReadPrettyFormBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/RecordReadPrettyFormBlockInitializer.tsx @@ -37,6 +37,7 @@ export const RecordReadPrettyFormBlockInitializer = () => { actionInitializers, association, collection: collection.name, + namespace: collection.namespace, action: 'get', useSourceId: '{{ useSourceIdFromParentRecord }}', useParams: '{{ useParamsFromRecord }}', @@ -55,6 +56,7 @@ export const RecordReadPrettyFormBlockInitializer = () => { actionInitializers, association, collection: collection.name, + namespace: collection.namespace, action: 'get', useSourceId: '{{ useSourceIdFromParentRecord }}', useParams: '{{ useParamsFromRecord }}', diff --git a/packages/core/client/src/schema-initializer/items/TableSelectorInitializer.tsx b/packages/core/client/src/schema-initializer/items/TableSelectorInitializer.tsx index 9bdcaa5c5c..ed5e75ab97 100644 --- a/packages/core/client/src/schema-initializer/items/TableSelectorInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/TableSelectorInitializer.tsx @@ -19,6 +19,7 @@ export const TableSelectorInitializer = () => { createTableSelectorSchema({ rowKey: collection.filterTargetKey, collection: collection.name, + namespace: collection.namespace, resource: collection.name, }), );