From d5f99d97dfd38c768ceed9ba9e5a8eed6d53a182 Mon Sep 17 00:00:00 2001 From: Katherine Date: Mon, 7 Apr 2025 16:02:51 +0800 Subject: [PATCH] fix: single-select field with 'contains' filter on mobile does not support multiple selection (#6629) --- .../interfaces/properties/operators.ts | 4 ++-- .../blocks/filter-blocks/FilterCollectionField.tsx | 2 +- .../schema-component/antd/filter/DynamicComponent.tsx | 1 - packages/core/client/src/schema-initializer/utils.ts | 7 +++---- .../pages/dynamic-page/components/MobilePicker.tsx | 9 +++++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/core/client/src/collection-manager/interfaces/properties/operators.ts b/packages/core/client/src/collection-manager/interfaces/properties/operators.ts index ce0b6d411f..80b4e31527 100644 --- a/packages/core/client/src/collection-manager/interfaces/properties/operators.ts +++ b/packages/core/client/src/collection-manager/interfaces/properties/operators.ts @@ -129,12 +129,12 @@ export const enumType = [ label: '{{t("is")}}', value: '$eq', selected: true, - schema: { 'x-component': 'Select' }, + schema: { 'x-component': 'Select', 'x-component-props': { mode: null } }, }, { label: '{{t("is not")}}', value: '$ne', - schema: { 'x-component': 'Select' }, + schema: { 'x-component': 'Select', 'x-component-props': { mode: null } }, }, { label: '{{t("is any of")}}', diff --git a/packages/core/client/src/modules/blocks/filter-blocks/FilterCollectionField.tsx b/packages/core/client/src/modules/blocks/filter-blocks/FilterCollectionField.tsx index 2f075ecaf3..a3e45281d1 100644 --- a/packages/core/client/src/modules/blocks/filter-blocks/FilterCollectionField.tsx +++ b/packages/core/client/src/modules/blocks/filter-blocks/FilterCollectionField.tsx @@ -96,7 +96,7 @@ export const FilterCollectionFieldInternalField: React.FC = (props: Props) => { const originalProps = compile({ ...(operator?.schema?.['x-component-props'] || {}), ...(uiSchema['x-component-props'] || {}) }) || {}; - field.componentProps = merge(originalProps, field.componentProps || {}, dynamicProps || {}); + field.componentProps = merge(field.componentProps || {}, originalProps, dynamicProps || {}); }, [uiSchemaOrigin]); if (!uiSchemaOrigin) return null; diff --git a/packages/core/client/src/schema-component/antd/filter/DynamicComponent.tsx b/packages/core/client/src/schema-component/antd/filter/DynamicComponent.tsx index 79025dabd2..2c5062344e 100644 --- a/packages/core/client/src/schema-component/antd/filter/DynamicComponent.tsx +++ b/packages/core/client/src/schema-component/antd/filter/DynamicComponent.tsx @@ -65,7 +65,6 @@ export const DynamicComponent = (props: Props) => { ...props.style, }, utc: false, - underFilter: true, }), name: 'value', 'x-read-pretty': false, diff --git a/packages/core/client/src/schema-initializer/utils.ts b/packages/core/client/src/schema-initializer/utils.ts index a279fcd751..b54f4643d2 100644 --- a/packages/core/client/src/schema-initializer/utils.ts +++ b/packages/core/client/src/schema-initializer/utils.ts @@ -470,7 +470,6 @@ export const useFilterFormItemInitializerFields = (options?: any) => { 'x-collection-field': `${name}.${field.name}`, 'x-component-props': { utc: false, - underFilter: true, }, }; if (isAssocField(field)) { @@ -485,7 +484,7 @@ export const useFilterFormItemInitializerFields = (options?: any) => { 'x-decorator': 'FormItem', 'x-use-decorator-props': 'useFormItemProps', 'x-collection-field': `${name}.${field.name}`, - 'x-component-props': { ...field.uiSchema?.['x-component-props'], utc: false, underFilter: true }, + 'x-component-props': { ...field.uiSchema?.['x-component-props'], utc: false }, }; } const resultItem = { @@ -580,7 +579,7 @@ const associationFieldToMenu = ( interface: field.interface, }, 'x-component': 'CollectionField', - 'x-component-props': { utc: false, underFilter: true }, + 'x-component-props': { utc: false }, 'x-read-pretty': false, 'x-decorator': 'FormItem', 'x-collection-field': `${collectionName}.${schemaName}`, @@ -697,7 +696,7 @@ export const useFilterInheritsFormItemInitializerFields = (options?) => { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', 'x-collection-field': `${name}.${field.name}`, - 'x-component-props': { utc: false, underFilter: true }, + 'x-component-props': { utc: false }, 'x-read-pretty': field?.uiSchema?.['x-read-pretty'], }; return { diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/components/MobilePicker.tsx b/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/components/MobilePicker.tsx index d02f503180..ac33034021 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/components/MobilePicker.tsx +++ b/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/components/MobilePicker.tsx @@ -16,6 +16,7 @@ import { useTranslation } from 'react-i18next'; const MobilePicker = connect( (props) => { const { value, onChange, disabled, options = [], mode } = props; + console.log(props); const { t } = useTranslation(); const [visible, setVisible] = useState(false); const [selected, setSelected] = useState(value || []); @@ -42,7 +43,7 @@ const MobilePicker = connect( disabled={disabled} value={value} dropdownStyle={{ display: 'none' }} - multiple={mode === 'multiple'} + multiple={['multiple', 'tags'].includes(mode)} onClear={() => { setVisible(false); onChange(null); @@ -77,10 +78,10 @@ const MobilePicker = connect( }} > { - if (mode === 'multiple') { + if (['multiple', 'tags'].includes(mode)) { setSelected(val); } else { setSelected(val[0]); @@ -96,7 +97,7 @@ const MobilePicker = connect( ))} - {mode === 'multiple' && ( + {['multiple', 'tags'].includes(mode) && (