diff --git a/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts b/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts index 838f92c3ab..755f21e494 100644 --- a/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts +++ b/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts @@ -17,13 +17,16 @@ import { SchemaSettings } from '../../../../application/schema-settings/SchemaSe import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../../collection-manager'; import { useFieldComponentName } from '../../../../common/useFieldComponentName'; import { fieldComponentSettingsItem } from '../../../../data-source/commonsSettingsItem'; -import { EditOperator, useDesignable, useValidateSchema, useCompile } from '../../../../schema-component'; +import { EditOperator, useCompile, useDesignable, useValidateSchema } from '../../../../schema-component'; import { SchemaSettingsDefaultValue } from '../../../../schema-settings/SchemaSettingsDefaultValue'; const fieldComponentNameMap = (name: string) => { if (name === 'Select') { return 'FilterSelect'; } + if (name === 'Picker') { + return 'FilterPicker'; + } return name; }; diff --git a/packages/core/client/src/modules/fields/component/Picker/recordPickerComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/Picker/recordPickerComponentFieldSettings.tsx index 39eb9cd68d..3e6895817b 100644 --- a/packages/core/client/src/modules/fields/component/Picker/recordPickerComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/Picker/recordPickerComponentFieldSettings.tsx @@ -17,7 +17,7 @@ import { useDesignable, useFieldModeOptions, useIsAddNewForm } from '../../../.. import { isSubMode } from '../../../../schema-component/antd/association-field/util'; import { allowAddNew, useIsFieldReadPretty } from '../../../../schema-component/antd/form-item/FormItem.Settings'; import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator'; -import { titleField } from '../Select/selectComponentFieldSettings'; +import { getAllowMultiple, titleField } from '../Select/selectComponentFieldSettings'; const allowMultiple: any = { name: 'allowMultiple', @@ -148,3 +148,52 @@ export const recordPickerComponentFieldSettings = new SchemaSettings({ titleField, ], }); + +// For filter form fields +export const filterRecordPickerComponentFieldSettings = new SchemaSettings({ + name: 'fieldSettings:component:FilterPicker', + items: [ + fieldComponent, + { + name: 'popupSize', + type: 'select', + useVisible() { + const isFieldReadPretty = useIsFieldReadPretty(); + return !isFieldReadPretty; + }, + useComponentProps() { + const { t } = useTranslation(); + const field = useField(); + const { fieldSchema: tableColumnSchema } = useColumnSchema(); + const schema = useFieldSchema(); + const fieldSchema = tableColumnSchema || schema; + const { dn } = useDesignable(); + return { + title: t('Popup size'), + options: [ + { label: t('Small'), value: 'small' }, + { label: t('Middle'), value: 'middle' }, + { label: t('Large'), value: 'large' }, + ], + value: + fieldSchema?.['x-component-props']?.['openSize'] ?? + (fieldSchema?.['x-component-props']?.['openMode'] == 'modal' ? 'large' : 'middle'), + onChange: (value) => { + field.componentProps.openSize = value; + fieldSchema['x-component-props'] = { ...fieldSchema['x-component-props'], openSize: value }; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + 'x-component-props': fieldSchema['x-component-props'], + }, + }); + dn.refresh(); + }, + }; + }, + }, + allowAddNew, + getAllowMultiple({ title: 'Allow multiple selection' }), + titleField, + ], +}); diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx index 43f32ea728..64d822964d 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx @@ -109,7 +109,8 @@ export const InternalPicker = observer( const pickerProps = { size: 'small', fieldNames, - multiple: multiple !== false && ['o2m', 'm2m', 'mbm'].includes(collectionField?.interface), + multiple: + multiple === true ? true : multiple !== false && ['o2m', 'm2m', 'mbm'].includes(collectionField?.interface), association: { target: collectionField?.target, }, @@ -147,7 +148,7 @@ export const InternalPicker = observer( setVisible(false); }, style: { - display: multiple !== false && ['o2m', 'm2m', 'mbm'].includes(collectionField?.interface) ? 'block' : 'none', + display: multiple === false ? 'none' : 'block', }, }; }; diff --git a/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts b/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts index 56187ea21f..e725eeded2 100644 --- a/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts +++ b/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts @@ -11,10 +11,10 @@ import { Plugin } from '../application/Plugin'; import { addChildActionSettings } from '../modules/actions/add-child/addChildActionSettings'; import { addNewActionSettings } from '../modules/actions/add-new/addNewActionSettings'; import { customizeAddRecordActionSettings } from '../modules/actions/add-record/customizeAddRecordActionSettings'; +import { associateActionSettings } from '../modules/actions/associate/associateActionSettings'; import { bulkDeleteActionSettings } from '../modules/actions/bulk-destroy/bulkDeleteActionSettings'; import { deleteActionSettings } from '../modules/actions/delete/deleteActionSettings'; import { disassociateActionSettings } from '../modules/actions/disassociate/disassociateActionSettings'; -import { associateActionSettings } from '../modules/actions/associate/associateActionSettings'; import { expendableActionSettings } from '../modules/actions/expand-collapse/expendableActionSettings'; import { filterActionSettings } from '../modules/actions/filter/filterActionSettings'; @@ -66,9 +66,13 @@ import { markdownSettings } from '../modules/fields/component/Markdown/markdownS import { markdownVditorSettings } from '../modules/fields/component/MarkdownVditor/markdownVditorSettings'; import { richTextSettings } from '../modules/fields/component/RichText/richTextSettings'; // import { inputURLComponentFieldSettings } from '../modules/fields/component/Input.URL/settings'; +import { dividerSettings } from '../modules/blocks/other-blocks/divider/dividerSettings'; import { inputNumberComponentFieldSettings } from '../modules/fields/component/InputNumber/inputNumberComponentFieldSettings'; import { subformComponentFieldSettings } from '../modules/fields/component/Nester/subformComponentFieldSettings'; -import { recordPickerComponentFieldSettings } from '../modules/fields/component/Picker/recordPickerComponentFieldSettings'; +import { + filterRecordPickerComponentFieldSettings, + recordPickerComponentFieldSettings, +} from '../modules/fields/component/Picker/recordPickerComponentFieldSettings'; import { subformPopoverComponentFieldSettings } from '../modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings'; import { filterSelectComponentFieldSettings, @@ -76,9 +80,8 @@ import { } from '../modules/fields/component/Select/selectComponentFieldSettings'; import { subTablePopoverComponentFieldSettings } from '../modules/fields/component/SubTable/subTablePopoverComponentFieldSettings'; import { tagComponentFieldSettings } from '../modules/fields/component/Tag/tagComponentFieldSettings'; -import { unixTimestampComponentFieldSettings } from '../modules/fields/component/UnixTimestamp/unixTimestampComponentFieldSettings'; -import { dividerSettings } from '../modules/blocks/other-blocks/divider/dividerSettings'; import { timePickerComponentFieldSettings } from '../modules/fields/component/TimePicker/timePickerComponentFieldSettings'; +import { unixTimestampComponentFieldSettings } from '../modules/fields/component/UnixTimestamp/unixTimestampComponentFieldSettings'; export class SchemaSettingsPlugin extends Plugin { async load() { // block settings @@ -127,6 +130,7 @@ export class SchemaSettingsPlugin extends Plugin { this.schemaSettingsManager.add(selectComponentFieldSettings); this.schemaSettingsManager.add(filterSelectComponentFieldSettings); this.schemaSettingsManager.add(recordPickerComponentFieldSettings); + this.schemaSettingsManager.add(filterRecordPickerComponentFieldSettings); this.schemaSettingsManager.add(subformComponentFieldSettings); this.schemaSettingsManager.add(subformPopoverComponentFieldSettings); this.schemaSettingsManager.add(subTablePopoverComponentFieldSettings);