refactor(collection-manager): collection &&fields support description config (#2554)

* refactor: collection support description config

* refactor: collection support description filter

* feat(collection-manager): collections & fields description fields

* refactor: collection& field support description

* refactor: collection& field support description

---------

Co-authored-by: ChengLei Shao <chareice@live.com>
This commit is contained in:
katherinehhh 2023-08-29 16:32:39 +08:00 committed by GitHub
parent 8b8199aca7
commit 83c1792582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 134 additions and 8 deletions

View File

@ -89,6 +89,12 @@ const getSchema = (schema: IField, record: any, compile) => {
},
// @ts-ignore
...properties,
description: {
type: 'string',
title: '{{t("Description")}}',
'x-decorator': 'FormItem',
'x-component': 'Input.TextArea',
},
footer: {
type: 'void',
'x-component': 'Action.Drawer.Footer',

View File

@ -25,6 +25,7 @@ import { OverridingCollectionField } from './OverridingCollectionField';
import { collection } from './schemas/collectionFields';
import { SyncFieldsAction } from './SyncFieldsAction';
import { ViewCollectionField } from './ViewInheritedField';
import { Input } from '../../schema-component/antd/input';
const indentStyle = css`
.ant-table {
@ -112,6 +113,11 @@ const CurrentFields = (props) => {
) : null;
},
},
{
dataIndex: 'description',
title: t('Descriptio '),
render: (value) => <Input.ReadPretty value={value} ellipsis={true} />,
},
{
dataIndex: 'actions',
title: t('Actions'),
@ -294,6 +300,10 @@ export const CollectionFields = () => {
dataIndex: 'titleField',
title: t('Title field'),
},
{
dataIndex: 'description',
title: t('Description'),
},
{
dataIndex: 'actions',
title: t('Actions'),
@ -395,6 +405,7 @@ export const CollectionFields = () => {
);
const addProps = { type: 'primary', database };
const syncProps = { type: 'primary' };
console.log(dataSource);
return (
<ResourceActionProvider {...resourceActionProps}>
<FormContext.Provider value={form}>

View File

@ -99,7 +99,6 @@ export const CollectionFieldsTableArray: React.FC<any> = observer(
const [categorizeData, setCategorizeData] = useState<Array<CategorizeDataItem>>([]);
const [expandedKeys, setExpendedKeys] = useState(selectedRowKeys);
const inherits = getInheritCollections(name);
const currentFields = getCurrentCollectionFields(name);
useDataSource({
onSuccess(data) {
field.value = data?.data || [];

View File

@ -81,6 +81,12 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
},
// @ts-ignore
...properties,
description: {
type: 'string',
title: '{{t("Description")}}',
'x-decorator': 'FormItem',
'x-component': 'Input.TextArea',
},
footer: {
type: 'void',
'x-component': 'Action.Drawer.Footer',

View File

@ -55,6 +55,12 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
},
// @ts-ignore
...properties,
description: {
type: 'string',
title: '{{t("Description")}}',
'x-decorator': 'FormItem',
'x-component': 'Input.TextArea',
},
footer: {
type: 'void',
'x-component': 'Action.Drawer.Footer',

View File

@ -55,6 +55,12 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
},
// @ts-ignore
...properties,
description: {
type: 'string',
title: '{{t("Description")}}',
'x-decorator': 'FormItem',
'x-component': 'Input.TextArea',
},
},
},
},

View File

@ -54,6 +54,16 @@ export const collection: CollectionOptions = {
'x-component': 'Input',
},
},
{
type: 'string',
name: 'description',
interface: 'input',
uiSchema: {
title: '{{ t("Description") }}',
type: 'string',
'x-component': 'Input.TextArea',
},
},
],
};
@ -172,6 +182,18 @@ export const collectionFieldSchema: ISchema = {
},
},
column4: {
type: 'void',
'x-decorator': 'Table.Column.Decorator',
'x-component': 'Table.Column',
title: '{{ t("Description") }}',
properties: {
interface: {
'x-component': 'CollectionField',
'x-read-pretty': true,
},
},
},
column5: {
type: 'void',
title: '{{ t("Actions") }}',
'x-component': 'Table.Column',

View File

@ -72,6 +72,16 @@ export const collection: CollectionOptions = {
},
},
},
{
type: 'string',
name: 'description',
interface: 'input',
uiSchema: {
title: '{{ t("Description") }}',
type: 'string',
'x-component': 'Input',
},
},
],
};
@ -231,6 +241,20 @@ export const collectionTableSchema: ISchema = {
},
},
column5: {
type: 'void',
'x-decorator': 'Table.Column.Decorator',
'x-component': 'Table.Column',
properties: {
description: {
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
column6: {
type: 'void',
title: '{{ t("Actions") }}',
'x-component': 'Table.Column',

View File

@ -51,5 +51,5 @@ export const calendar: ICollectionTemplate = {
availableFieldInterfaces: {
include: [],
},
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'description'),
};

View File

@ -54,5 +54,5 @@ export const expression: ICollectionTemplate = {
availableFieldInterfaces: {
include: [],
},
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'description'),
};

View File

@ -9,5 +9,12 @@ export const general: ICollectionTemplate = {
default: {
fields: [],
},
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'moreOptions'),
configurableProperties: getConfigurableProperties(
'title',
'name',
'inherits',
'category',
'description',
'moreOptions',
),
};

View File

@ -113,6 +113,13 @@ export const defaultConfigurableProperties = {
},
'x-reactions': ['{{useAsyncDataSource(loadCategories)}}'],
},
description: {
title: '{{t("Description")}}',
type: 'string',
name: 'description',
'x-decorator': 'FormItem',
'x-component': 'Input.TextArea',
},
...moreOptions,
moreOptions: {
title: '{{t("More options")}}',
@ -142,6 +149,7 @@ export type DefaultConfigurableKeys =
| 'createdAt'
| 'updatedAt'
| 'sortable'
| 'description'
| 'moreOptions';
export const getConfigurableProperties = (...keys: DefaultConfigurableKeys[]) => {

View File

@ -72,5 +72,12 @@ export const tree: ICollectionTemplate = {
}
},
},
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'moreOptions'),
configurableProperties: getConfigurableProperties(
'title',
'name',
'inherits',
'category',
'description',
'moreOptions',
),
};

View File

@ -136,6 +136,6 @@ export const view: ICollectionTemplate = {
},
},
...getConfigurableProperties('category'),
...getConfigurableProperties('category', 'description'),
},
};

View File

@ -7,7 +7,7 @@ import { JSONTextAreaProps, Json } from './Json';
import { ReadPretty } from './ReadPretty';
type ComposedInput = React.FC<InputProps> & {
ReadPretty: React.FC<InputProps>;
ReadPretty: React.FC<InputProps | { ellipsis?: boolean }>;
TextArea: React.FC<TextAreaProps>;
URL: React.FC<InputProps>;
JSON: React.FC<JSONTextAreaProps>;

View File

@ -20,6 +20,20 @@ describe('collections repository', () => {
await app.destroy();
});
it('should create collection with description', async () => {
const description = 'this collection is for tests';
await Collection.repository.create({
values: {
name: 'posts',
description,
},
context: {},
});
const postsCollection = db.getCollection('posts');
expect(postsCollection.options.description).toEqual(description);
});
it('should extend collections collection', async () => {
expect(db.getRepository<CollectionRepository>('collections')).toBeTruthy();

View File

@ -44,6 +44,11 @@ export default {
name: 'options',
defaultValue: {},
},
{
type: 'string',
name: 'description',
allowNull: true,
},
{
type: 'hasMany',
name: 'fields',

View File

@ -37,6 +37,11 @@ export default {
name: 'interface',
allowNull: true,
},
{
type: 'string',
name: 'description',
allowNull: true,
},
{
type: 'belongsTo',
name: 'collection',

View File

@ -140,7 +140,7 @@ export const file = {
...getConfigurableProperties('inherits').inherits,
'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'],
},
...getConfigurableProperties('category'),
...getConfigurableProperties('category', 'description'),
storage: {
title: `{{t("File storage", { ns: "${NAMESPACE}" })}}`,
type: 'hasOne',