feat(client): search and select collection
This commit is contained in:
parent
72838b7f49
commit
406813e932
@ -581,4 +581,5 @@ export default {
|
|||||||
"Please select the records to be updated": "Please select the records to be updated",
|
"Please select the records to be updated": "Please select the records to be updated",
|
||||||
"Selector": "Selector",
|
"Selector": "Selector",
|
||||||
"Inner": "Inner",
|
"Inner": "Inner",
|
||||||
|
"Search and select collection": "Search and select collection",
|
||||||
}
|
}
|
||||||
|
@ -588,4 +588,5 @@ export default {
|
|||||||
"Error message": "エラーメッセージ",
|
"Error message": "エラーメッセージ",
|
||||||
"Record picker": "レコードピッカー",
|
"Record picker": "レコードピッカー",
|
||||||
"Sortable": "ソート可能",
|
"Sortable": "ソート可能",
|
||||||
|
"Search and select collection": "Search and select collection",
|
||||||
}
|
}
|
||||||
|
@ -557,4 +557,5 @@ export default {
|
|||||||
"Print": "Печать",
|
"Print": "Печать",
|
||||||
'Single select and radio fields can be used as the grouping field': 'Одиночное поле выбора и радиополя могут использоваться в качестве поля группировки',
|
'Single select and radio fields can be used as the grouping field': 'Одиночное поле выбора и радиополя могут использоваться в качестве поля группировки',
|
||||||
'Sign up successfully, and automatically jump to the sign in page': 'Зарегистрируйтесь успешно и автоматически перейдете на страницу входа',
|
'Sign up successfully, and automatically jump to the sign in page': 'Зарегистрируйтесь успешно и автоматически перейдете на страницу входа',
|
||||||
|
"Search and select collection": "Search and select collection",
|
||||||
}
|
}
|
||||||
|
@ -556,4 +556,5 @@ export default {
|
|||||||
"Print": "Yazdır",
|
"Print": "Yazdır",
|
||||||
'Single select and radio fields can be used as the grouping field': 'Gruplama alanı olarak tek seçim ve radyo alanları kullanılabilir',
|
'Single select and radio fields can be used as the grouping field': 'Gruplama alanı olarak tek seçim ve radyo alanları kullanılabilir',
|
||||||
'Sign up successfully, and automatically jump to the sign in page': 'Başarılı bir şekilde kaydolun ve otomatik olarak oturum açma sayfasına geçin',
|
'Sign up successfully, and automatically jump to the sign in page': 'Başarılı bir şekilde kaydolun ve otomatik olarak oturum açma sayfasına geçin',
|
||||||
|
"Search and select collection": "Search and select collection",
|
||||||
}
|
}
|
||||||
|
@ -734,4 +734,5 @@ export default {
|
|||||||
"Please select the records to be updated": "请选择要更新的记录",
|
"Please select the records to be updated": "请选择要更新的记录",
|
||||||
"Selector": "选择器",
|
"Selector": "选择器",
|
||||||
"Inner": "里面",
|
"Inner": "里面",
|
||||||
|
"Search and select collection": "搜索并选择数据表",
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,7 @@ SchemaInitializer.Item = (props: SchemaInitializerItemProps) => {
|
|||||||
eventKey={item.key}
|
eventKey={item.key}
|
||||||
key={item.key}
|
key={item.key}
|
||||||
onClick={(info) => {
|
onClick={(info) => {
|
||||||
|
item?.clearKeywords();
|
||||||
onClick({ ...info, item });
|
onClick({ ...info, item });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -215,6 +216,7 @@ SchemaInitializer.Item = (props: SchemaInitializerItemProps) => {
|
|||||||
eventKey={eventKey ? `${eventKey}-${index}` : info.key}
|
eventKey={eventKey ? `${eventKey}-${index}` : info.key}
|
||||||
icon={typeof icon === 'string' ? <Icon type={icon as string} /> : icon}
|
icon={typeof icon === 'string' ? <Icon type={icon as string} /> : icon}
|
||||||
onClick={(opts) => {
|
onClick={(opts) => {
|
||||||
|
info?.clearKeywords();
|
||||||
onClick({ ...opts, item: info });
|
onClick({ ...opts, item: info });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
import { Divider, Input } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useCollectionManager } from '../collection-manager';
|
||||||
|
|
||||||
|
export const SelectCollection = ({ value, onChange, setSelected }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { collections } = useCollectionManager();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ width: 210 }}>
|
||||||
|
<Input
|
||||||
|
allowClear
|
||||||
|
style={{ padding: '0 4px 6px' }}
|
||||||
|
bordered={false}
|
||||||
|
placeholder={t('Search and select collection')}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => {
|
||||||
|
const names = collections
|
||||||
|
.filter((collection) => {
|
||||||
|
if (!collection.title) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return collection.title.toUpperCase().includes(e.target.value.toUpperCase());
|
||||||
|
})
|
||||||
|
.map((item) => item.name);
|
||||||
|
setSelected(names);
|
||||||
|
onChange(e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Divider style={{ margin: 0 }}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -1,10 +1,12 @@
|
|||||||
import { ISchema, Schema, useFieldSchema, useForm } from '@formily/react';
|
import { ISchema, Schema, useFieldSchema, useForm } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
|
import React, { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { SchemaInitializerItemOptions } from '../';
|
import { SchemaInitializerItemOptions } from '../';
|
||||||
import { useCollection, useCollectionManager } from '../collection-manager';
|
import { useCollection, useCollectionManager } from '../collection-manager';
|
||||||
import { useDesignable } from '../schema-component';
|
import { useDesignable } from '../schema-component';
|
||||||
import { useSchemaTemplateManager } from '../schema-templates';
|
import { useSchemaTemplateManager } from '../schema-templates';
|
||||||
|
import { SelectCollection } from './SelectCollection';
|
||||||
|
|
||||||
export const itemsMerge = (items1, items2) => {
|
export const itemsMerge = (items1, items2) => {
|
||||||
return items1;
|
return items1;
|
||||||
@ -427,17 +429,28 @@ export const useCollectionDataSourceItems = (componentName) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { collections } = useCollectionManager();
|
const { collections } = useCollectionManager();
|
||||||
const { getTemplatesByCollection } = useSchemaTemplateManager();
|
const { getTemplatesByCollection } = useSchemaTemplateManager();
|
||||||
|
const [selected, setSelected] = useState([]);
|
||||||
|
const [value, onChange] = useState(null);
|
||||||
|
const clearKeywords = () => {
|
||||||
|
setSelected([]);
|
||||||
|
onChange(null);
|
||||||
|
};
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
key: 'tableBlock',
|
key: 'tableBlock',
|
||||||
type: 'itemGroup',
|
type: 'itemGroup',
|
||||||
title: t('Select collection'),
|
title: React.createElement(SelectCollection, {
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
setSelected,
|
||||||
|
}),
|
||||||
children: collections
|
children: collections
|
||||||
?.filter((item) => {
|
?.filter((item) => {
|
||||||
if(item.inherit){
|
const b = !value || selected.includes(item.name);
|
||||||
return false
|
if (item.inherit) {
|
||||||
}else{
|
return false;
|
||||||
return !(item?.isThrough && item?.autoCreate);
|
} else {
|
||||||
|
return b && !(item?.isThrough && item?.autoCreate);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
?.map((item, index) => {
|
?.map((item, index) => {
|
||||||
@ -453,6 +466,7 @@ export const useCollectionDataSourceItems = (componentName) => {
|
|||||||
type: 'item',
|
type: 'item',
|
||||||
name: item.name,
|
name: item.name,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
|
clearKeywords,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -465,6 +479,7 @@ export const useCollectionDataSourceItems = (componentName) => {
|
|||||||
type: 'item',
|
type: 'item',
|
||||||
name: item.name,
|
name: item.name,
|
||||||
title: t('Blank block'),
|
title: t('Blank block'),
|
||||||
|
clearKeywords,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'divider',
|
type: 'divider',
|
||||||
@ -482,6 +497,7 @@ export const useCollectionDataSourceItems = (componentName) => {
|
|||||||
mode: 'copy',
|
mode: 'copy',
|
||||||
name: item.name,
|
name: item.name,
|
||||||
template,
|
template,
|
||||||
|
clearKeywords,
|
||||||
title: templateName || t('Untitled'),
|
title: templateName || t('Untitled'),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
@ -497,6 +513,7 @@ export const useCollectionDataSourceItems = (componentName) => {
|
|||||||
return {
|
return {
|
||||||
type: 'item',
|
type: 'item',
|
||||||
mode: 'reference',
|
mode: 'reference',
|
||||||
|
clearKeywords,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
template,
|
template,
|
||||||
title: templateName || t('Untitled'),
|
title: templateName || t('Untitled'),
|
||||||
|
Loading…
Reference in New Issue
Block a user