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 1d68668885..2c8051426a 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 }) => {