From cf0a62a502405a397231c93bd34cdf2b6fedc712 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Tue, 29 Oct 2024 20:07:42 +0800 Subject: [PATCH] fix(m2m-array): issue where select component for a m2m array field has only one option (#5544) --- .../core/client/src/collection-manager/interfaces/index.ts | 2 ++ .../@nocobase/plugin-field-m2m-array/src/client/mbm.ts | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) 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';