diff --git a/packages/core/client/src/collection-manager/interfaces/index.ts b/packages/core/client/src/collection-manager/interfaces/index.ts index e2a1dfd747..2a25abb4a3 100644 --- a/packages/core/client/src/collection-manager/interfaces/index.ts +++ b/packages/core/client/src/collection-manager/interfaces/index.ts @@ -48,3 +48,5 @@ export * from './nanoid'; export * from './unixTimestamp'; export * from './dateOnly'; export * from './datetimeNoTz'; + +export { getUniqueKeyFromCollection } from './utils'; diff --git a/packages/plugins/@nocobase/plugin-field-m2m-array/src/client/mbm.ts b/packages/plugins/@nocobase/plugin-field-m2m-array/src/client/mbm.ts index 5e9acd0bda..f64df33258 100644 --- a/packages/plugins/@nocobase/plugin-field-m2m-array/src/client/mbm.ts +++ b/packages/plugins/@nocobase/plugin-field-m2m-array/src/client/mbm.ts @@ -8,14 +8,10 @@ */ import { ISchema } from '@formily/react'; -import { Collection, CollectionFieldInterface } from '@nocobase/client'; +import { CollectionFieldInterface, getUniqueKeyFromCollection } from '@nocobase/client'; import { tval } from '@nocobase/utils/client'; import { NAMESPACE } from './locale'; -function getUniqueKeyFromCollection(collection: Collection) { - return collection?.filterTargetKey?.[0] || collection?.filterTargetKey || collection?.getPrimaryKey() || 'id'; -} - export class MBMFieldInterface extends CollectionFieldInterface { name = 'mbm'; type = 'object';