feat(client): allow search by title in collection select (#1869)

This commit is contained in:
Junyi 2023-05-16 16:07:56 +07:00 committed by GitHub
parent 29956150ba
commit 0eb1c31514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -35,7 +35,7 @@ export const expression: ICollectionTemplate = {
title: '{{t("Collection")}}',
'x-component': 'CollectionSelect',
'x-component-props': {
multiple: true,
// multiple: true,
},
},
},

View File

@ -28,7 +28,15 @@ export const CollectionSelect = connect(
const options = useOptions(props);
const { t } = useTranslation();
return <Select placeholder={t('Select collection')} {...others} options={options} />;
return (
<Select
placeholder={t('Select collection')}
{...others}
showSearch
filterOption={(input, option) => (option?.label ?? '').includes(input)}
options={options}
/>
);
},
mapReadPretty(
observer((props: CollectionSelectProps) => {

View File

@ -7,12 +7,11 @@ export const collection = {
type: 'string',
title: '{{t("Collection")}}',
required: true,
'x-reactions': ['{{useCollectionDataSource()}}'],
'x-reactions': [],
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component': 'CollectionSelect',
'x-component-props': {
dropdownMatchSelectWidth: false,
placeholder: '{{t("Select collection")}}',
},
};