From 435dc80a78d1b768e162f9f1d2b038d1886ceee9 Mon Sep 17 00:00:00 2001 From: Katherine Date: Fri, 7 Feb 2025 17:03:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20"Select=20from=20existing=20data"=20stil?= =?UTF-8?q?l=20showing=20when=20disable=20=E2=80=9CAllow=20mu=E2=80=A6=20(?= =?UTF-8?q?#6167)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: "Select from existing data" still showing when disable “Allow multiple ” in to-many subform * fix: bug --- lerna.json | 4 +--- .../SubTable/subTablePopoverComponentFieldSettings.tsx | 7 +++++-- .../src/schema-component/antd/association-field/Nester.tsx | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lerna.json b/lerna.json index 2af4d2de84..e9ee616a66 100644 --- a/lerna.json +++ b/lerna.json @@ -2,9 +2,7 @@ "version": "1.6.0-alpha.22", "npmClient": "yarn", "useWorkspaces": true, - "npmClientArgs": [ - "--ignore-engines" - ], + "npmClientArgs": ["--ignore-engines"], "command": { "version": { "forcePublish": true, diff --git a/packages/core/client/src/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.tsx index b49b48a392..d5b5ae25d3 100644 --- a/packages/core/client/src/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.tsx @@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next'; import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { useCollectionManager_deprecated, useSortFields } from '../../../../collection-manager'; import { useFieldComponentName } from '../../../../common/useFieldComponentName'; -import { useCollectionManager, useRerenderDataBlock } from '../../../../data-source'; +import { useCollectionManager, useRerenderDataBlock, useCollectionField } from '../../../../data-source'; import { FlagProvider } from '../../../../flag-provider/FlagProvider'; import { withDynamicSchemaProps } from '../../../../hoc/withDynamicSchemaProps'; import { @@ -76,8 +76,11 @@ export const allowSelectExistingRecord = { name: 'allowSelectExistingRecord', type: 'switch', useVisible() { + const fieldSchema = useFieldSchema(); + const { multiple } = fieldSchema['x-component-props']; const readPretty = useIsFieldReadPretty(); - return !readPretty; + const collectionField = useCollectionField(); + return !readPretty && multiple !== false && ['hasMany', 'belongsToMany'].includes(collectionField?.type); }, useComponentProps() { const { t } = useTranslation(); diff --git a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx index 94447d6491..0b5f1a59e2 100644 --- a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx @@ -322,7 +322,7 @@ const ToManyNester = observer( } /> )} - {field.editable && allowSelectExistingRecord && currentMode === 'Nester' && ( + {field.editable && allowSelectExistingRecord && currentMode === 'Nester' && allowMultiple && (