From c3ddeaa46f3d67d28c9d851f1b362da6a5bdebab Mon Sep 17 00:00:00 2001 From: Katherine Date: Thu, 1 Aug 2024 11:32:43 +0800 Subject: [PATCH] fix: collection manager support filterTargetKey setting (#4968) * fix: edit collection support filterTargetKey setting * fix: edit collection support filterTargetKey setting * fix: external collection support filterTargetKey setting --- .../Configuration/EditCollectionAction.tsx | 8 ++++++++ .../component/CollectionsManager/EditCollectionAction.tsx | 1 - .../Configuration/ConfigurationTable.tsx | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx b/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx index ed036fb757..6bf545b4d8 100644 --- a/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx @@ -58,6 +58,14 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema title: '{{ t("Edit collection") }}', properties: { ...properties, + filterTargetKey: { + title: `{{ t("Record unique key")}}`, + type: 'single', + description: `{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}`, + 'x-decorator': 'FormItem', + 'x-component': 'Select', + 'x-reactions': ['{{useAsyncDataSource(loadFilterTargetKeys)}}'], + }, footer: { type: 'void', 'x-component': 'Action.Drawer.Footer', diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx index 098b53b807..09ac2749b7 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx @@ -78,7 +78,6 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema 'x-decorator': 'FormItem', 'x-component': 'Select', enum: '{{filterTargetKeyOptions}}', - 'x-visible': '{{!!isView}}', }, footer: { type: 'void', diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx index 6ed2d5f809..3a78e86478 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx @@ -29,6 +29,7 @@ import { FieldSummary, TemplateSummary, useRequest, + useCollectionRecordData, } from '@nocobase/client'; import { CollectionFields } from './CollectionFields'; import { collectionSchema } from './schemas/collections'; @@ -101,7 +102,7 @@ const useNewId = (prefix) => { export const ConfigurationTable = () => { const { t } = useTranslation(); - const { interfaces, getCollections } = useCollectionManager_deprecated(); + const { interfaces, getCollections, getCollection } = useCollectionManager_deprecated(); const { data: { database }, } = useCurrentAppInfo(); @@ -163,7 +164,8 @@ export const ConfigurationTable = () => { }; const loadFilterTargetKeys = async (field) => { - const { fields } = field.form.values; + const { name } = field.form.values; + const { fields } = getCollection(name); return Promise.resolve({ data: fields, }).then(({ data }) => {