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:
parent
8b8199aca7
commit
83c1792582
@ -89,6 +89,12 @@ const getSchema = (schema: IField, record: any, compile) => {
|
|||||||
},
|
},
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...properties,
|
...properties,
|
||||||
|
description: {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Description")}}',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input.TextArea',
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Action.Drawer.Footer',
|
'x-component': 'Action.Drawer.Footer',
|
||||||
|
@ -25,6 +25,7 @@ import { OverridingCollectionField } from './OverridingCollectionField';
|
|||||||
import { collection } from './schemas/collectionFields';
|
import { collection } from './schemas/collectionFields';
|
||||||
import { SyncFieldsAction } from './SyncFieldsAction';
|
import { SyncFieldsAction } from './SyncFieldsAction';
|
||||||
import { ViewCollectionField } from './ViewInheritedField';
|
import { ViewCollectionField } from './ViewInheritedField';
|
||||||
|
import { Input } from '../../schema-component/antd/input';
|
||||||
|
|
||||||
const indentStyle = css`
|
const indentStyle = css`
|
||||||
.ant-table {
|
.ant-table {
|
||||||
@ -112,6 +113,11 @@ const CurrentFields = (props) => {
|
|||||||
) : null;
|
) : null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
dataIndex: 'description',
|
||||||
|
title: t('Descriptio '),
|
||||||
|
render: (value) => <Input.ReadPretty value={value} ellipsis={true} />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
dataIndex: 'actions',
|
dataIndex: 'actions',
|
||||||
title: t('Actions'),
|
title: t('Actions'),
|
||||||
@ -294,6 +300,10 @@ export const CollectionFields = () => {
|
|||||||
dataIndex: 'titleField',
|
dataIndex: 'titleField',
|
||||||
title: t('Title field'),
|
title: t('Title field'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
dataIndex: 'description',
|
||||||
|
title: t('Description'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
dataIndex: 'actions',
|
dataIndex: 'actions',
|
||||||
title: t('Actions'),
|
title: t('Actions'),
|
||||||
@ -395,6 +405,7 @@ export const CollectionFields = () => {
|
|||||||
);
|
);
|
||||||
const addProps = { type: 'primary', database };
|
const addProps = { type: 'primary', database };
|
||||||
const syncProps = { type: 'primary' };
|
const syncProps = { type: 'primary' };
|
||||||
|
console.log(dataSource);
|
||||||
return (
|
return (
|
||||||
<ResourceActionProvider {...resourceActionProps}>
|
<ResourceActionProvider {...resourceActionProps}>
|
||||||
<FormContext.Provider value={form}>
|
<FormContext.Provider value={form}>
|
||||||
|
@ -99,7 +99,6 @@ export const CollectionFieldsTableArray: React.FC<any> = observer(
|
|||||||
const [categorizeData, setCategorizeData] = useState<Array<CategorizeDataItem>>([]);
|
const [categorizeData, setCategorizeData] = useState<Array<CategorizeDataItem>>([]);
|
||||||
const [expandedKeys, setExpendedKeys] = useState(selectedRowKeys);
|
const [expandedKeys, setExpendedKeys] = useState(selectedRowKeys);
|
||||||
const inherits = getInheritCollections(name);
|
const inherits = getInheritCollections(name);
|
||||||
const currentFields = getCurrentCollectionFields(name);
|
|
||||||
useDataSource({
|
useDataSource({
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
field.value = data?.data || [];
|
field.value = data?.data || [];
|
||||||
|
@ -81,6 +81,12 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
|
|||||||
},
|
},
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...properties,
|
...properties,
|
||||||
|
description: {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Description")}}',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input.TextArea',
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Action.Drawer.Footer',
|
'x-component': 'Action.Drawer.Footer',
|
||||||
|
@ -55,6 +55,12 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
|
|||||||
},
|
},
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...properties,
|
...properties,
|
||||||
|
description: {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Description")}}',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input.TextArea',
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Action.Drawer.Footer',
|
'x-component': 'Action.Drawer.Footer',
|
||||||
|
@ -55,6 +55,12 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
|
|||||||
},
|
},
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...properties,
|
...properties,
|
||||||
|
description: {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Description")}}',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input.TextArea',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -54,6 +54,16 @@ export const collection: CollectionOptions = {
|
|||||||
'x-component': 'Input',
|
'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: {
|
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',
|
type: 'void',
|
||||||
title: '{{ t("Actions") }}',
|
title: '{{ t("Actions") }}',
|
||||||
'x-component': 'Table.Column',
|
'x-component': 'Table.Column',
|
||||||
|
@ -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: {
|
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',
|
type: 'void',
|
||||||
title: '{{ t("Actions") }}',
|
title: '{{ t("Actions") }}',
|
||||||
'x-component': 'Table.Column',
|
'x-component': 'Table.Column',
|
||||||
|
@ -51,5 +51,5 @@ export const calendar: ICollectionTemplate = {
|
|||||||
availableFieldInterfaces: {
|
availableFieldInterfaces: {
|
||||||
include: [],
|
include: [],
|
||||||
},
|
},
|
||||||
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
|
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'description'),
|
||||||
};
|
};
|
||||||
|
@ -54,5 +54,5 @@ export const expression: ICollectionTemplate = {
|
|||||||
availableFieldInterfaces: {
|
availableFieldInterfaces: {
|
||||||
include: [],
|
include: [],
|
||||||
},
|
},
|
||||||
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
|
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'description'),
|
||||||
};
|
};
|
||||||
|
@ -9,5 +9,12 @@ export const general: ICollectionTemplate = {
|
|||||||
default: {
|
default: {
|
||||||
fields: [],
|
fields: [],
|
||||||
},
|
},
|
||||||
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'moreOptions'),
|
configurableProperties: getConfigurableProperties(
|
||||||
|
'title',
|
||||||
|
'name',
|
||||||
|
'inherits',
|
||||||
|
'category',
|
||||||
|
'description',
|
||||||
|
'moreOptions',
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
@ -113,6 +113,13 @@ export const defaultConfigurableProperties = {
|
|||||||
},
|
},
|
||||||
'x-reactions': ['{{useAsyncDataSource(loadCategories)}}'],
|
'x-reactions': ['{{useAsyncDataSource(loadCategories)}}'],
|
||||||
},
|
},
|
||||||
|
description: {
|
||||||
|
title: '{{t("Description")}}',
|
||||||
|
type: 'string',
|
||||||
|
name: 'description',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input.TextArea',
|
||||||
|
},
|
||||||
...moreOptions,
|
...moreOptions,
|
||||||
moreOptions: {
|
moreOptions: {
|
||||||
title: '{{t("More options")}}',
|
title: '{{t("More options")}}',
|
||||||
@ -142,6 +149,7 @@ export type DefaultConfigurableKeys =
|
|||||||
| 'createdAt'
|
| 'createdAt'
|
||||||
| 'updatedAt'
|
| 'updatedAt'
|
||||||
| 'sortable'
|
| 'sortable'
|
||||||
|
| 'description'
|
||||||
| 'moreOptions';
|
| 'moreOptions';
|
||||||
|
|
||||||
export const getConfigurableProperties = (...keys: DefaultConfigurableKeys[]) => {
|
export const getConfigurableProperties = (...keys: DefaultConfigurableKeys[]) => {
|
||||||
|
@ -72,5 +72,12 @@ export const tree: ICollectionTemplate = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'moreOptions'),
|
configurableProperties: getConfigurableProperties(
|
||||||
|
'title',
|
||||||
|
'name',
|
||||||
|
'inherits',
|
||||||
|
'category',
|
||||||
|
'description',
|
||||||
|
'moreOptions',
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
@ -136,6 +136,6 @@ export const view: ICollectionTemplate = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
...getConfigurableProperties('category'),
|
...getConfigurableProperties('category', 'description'),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ import { JSONTextAreaProps, Json } from './Json';
|
|||||||
import { ReadPretty } from './ReadPretty';
|
import { ReadPretty } from './ReadPretty';
|
||||||
|
|
||||||
type ComposedInput = React.FC<InputProps> & {
|
type ComposedInput = React.FC<InputProps> & {
|
||||||
ReadPretty: React.FC<InputProps>;
|
ReadPretty: React.FC<InputProps | { ellipsis?: boolean }>;
|
||||||
TextArea: React.FC<TextAreaProps>;
|
TextArea: React.FC<TextAreaProps>;
|
||||||
URL: React.FC<InputProps>;
|
URL: React.FC<InputProps>;
|
||||||
JSON: React.FC<JSONTextAreaProps>;
|
JSON: React.FC<JSONTextAreaProps>;
|
||||||
|
@ -20,6 +20,20 @@ describe('collections repository', () => {
|
|||||||
await app.destroy();
|
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 () => {
|
it('should extend collections collection', async () => {
|
||||||
expect(db.getRepository<CollectionRepository>('collections')).toBeTruthy();
|
expect(db.getRepository<CollectionRepository>('collections')).toBeTruthy();
|
||||||
|
|
||||||
|
@ -44,6 +44,11 @@ export default {
|
|||||||
name: 'options',
|
name: 'options',
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'description',
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'hasMany',
|
type: 'hasMany',
|
||||||
name: 'fields',
|
name: 'fields',
|
||||||
|
@ -37,6 +37,11 @@ export default {
|
|||||||
name: 'interface',
|
name: 'interface',
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'description',
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'belongsTo',
|
type: 'belongsTo',
|
||||||
name: 'collection',
|
name: 'collection',
|
||||||
|
@ -140,7 +140,7 @@ export const file = {
|
|||||||
...getConfigurableProperties('inherits').inherits,
|
...getConfigurableProperties('inherits').inherits,
|
||||||
'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'],
|
'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'],
|
||||||
},
|
},
|
||||||
...getConfigurableProperties('category'),
|
...getConfigurableProperties('category', 'description'),
|
||||||
storage: {
|
storage: {
|
||||||
title: `{{t("File storage", { ns: "${NAMESPACE}" })}}`,
|
title: `{{t("File storage", { ns: "${NAMESPACE}" })}}`,
|
||||||
type: 'hasOne',
|
type: 'hasOne',
|
||||||
|
Loading…
Reference in New Issue
Block a user