diff --git a/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx b/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx
index 03f3a55ba..0041b5968 100644
--- a/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx
+++ b/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx
@@ -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',
diff --git a/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx b/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx
index 30d035486..1c9105065 100644
--- a/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx
+++ b/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx
@@ -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) => ,
+ },
{
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 (
diff --git a/packages/core/client/src/collection-manager/Configuration/CollectionFieldsTableArray.tsx b/packages/core/client/src/collection-manager/Configuration/CollectionFieldsTableArray.tsx
index a99af6ba0..85ffba040 100644
--- a/packages/core/client/src/collection-manager/Configuration/CollectionFieldsTableArray.tsx
+++ b/packages/core/client/src/collection-manager/Configuration/CollectionFieldsTableArray.tsx
@@ -99,7 +99,6 @@ export const CollectionFieldsTableArray: React.FC = observer(
const [categorizeData, setCategorizeData] = useState>([]);
const [expandedKeys, setExpendedKeys] = useState(selectedRowKeys);
const inherits = getInheritCollections(name);
- const currentFields = getCurrentCollectionFields(name);
useDataSource({
onSuccess(data) {
field.value = data?.data || [];
diff --git a/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx b/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx
index 5a1535e63..570f001ed 100644
--- a/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx
+++ b/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx
@@ -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',
diff --git a/packages/core/client/src/collection-manager/Configuration/OverridingCollectionField.tsx b/packages/core/client/src/collection-manager/Configuration/OverridingCollectionField.tsx
index a62b560af..261a062bf 100644
--- a/packages/core/client/src/collection-manager/Configuration/OverridingCollectionField.tsx
+++ b/packages/core/client/src/collection-manager/Configuration/OverridingCollectionField.tsx
@@ -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',
diff --git a/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx b/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx
index 94da22b84..5a918f56e 100644
--- a/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx
+++ b/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx
@@ -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',
+ },
},
},
},
diff --git a/packages/core/client/src/collection-manager/Configuration/schemas/collectionFields.ts b/packages/core/client/src/collection-manager/Configuration/schemas/collectionFields.ts
index b89e4f03d..cbea11e59 100644
--- a/packages/core/client/src/collection-manager/Configuration/schemas/collectionFields.ts
+++ b/packages/core/client/src/collection-manager/Configuration/schemas/collectionFields.ts
@@ -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',
diff --git a/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts b/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts
index 1428c711d..4a78e1d87 100644
--- a/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts
+++ b/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts
@@ -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',
diff --git a/packages/core/client/src/collection-manager/templates/calendar.tsx b/packages/core/client/src/collection-manager/templates/calendar.tsx
index 5a51c42bf..f74ec9413 100644
--- a/packages/core/client/src/collection-manager/templates/calendar.tsx
+++ b/packages/core/client/src/collection-manager/templates/calendar.tsx
@@ -51,5 +51,5 @@ export const calendar: ICollectionTemplate = {
availableFieldInterfaces: {
include: [],
},
- configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
+ configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'description'),
};
diff --git a/packages/core/client/src/collection-manager/templates/expression.tsx b/packages/core/client/src/collection-manager/templates/expression.tsx
index 2f50b90b1..d94b764ee 100644
--- a/packages/core/client/src/collection-manager/templates/expression.tsx
+++ b/packages/core/client/src/collection-manager/templates/expression.tsx
@@ -54,5 +54,5 @@ export const expression: ICollectionTemplate = {
availableFieldInterfaces: {
include: [],
},
- configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
+ configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'description'),
};
diff --git a/packages/core/client/src/collection-manager/templates/general.tsx b/packages/core/client/src/collection-manager/templates/general.tsx
index 347ebd5f7..c3078e3cc 100644
--- a/packages/core/client/src/collection-manager/templates/general.tsx
+++ b/packages/core/client/src/collection-manager/templates/general.tsx
@@ -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',
+ ),
};
diff --git a/packages/core/client/src/collection-manager/templates/properties/index.ts b/packages/core/client/src/collection-manager/templates/properties/index.ts
index c6d7c3cd3..8256e1ff3 100644
--- a/packages/core/client/src/collection-manager/templates/properties/index.ts
+++ b/packages/core/client/src/collection-manager/templates/properties/index.ts
@@ -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[]) => {
diff --git a/packages/core/client/src/collection-manager/templates/tree.tsx b/packages/core/client/src/collection-manager/templates/tree.tsx
index 31fc3c17a..e472df660 100644
--- a/packages/core/client/src/collection-manager/templates/tree.tsx
+++ b/packages/core/client/src/collection-manager/templates/tree.tsx
@@ -72,5 +72,12 @@ export const tree: ICollectionTemplate = {
}
},
},
- configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category', 'moreOptions'),
+ configurableProperties: getConfigurableProperties(
+ 'title',
+ 'name',
+ 'inherits',
+ 'category',
+ 'description',
+ 'moreOptions',
+ ),
};
diff --git a/packages/core/client/src/collection-manager/templates/view.tsx b/packages/core/client/src/collection-manager/templates/view.tsx
index f2308f6e9..12dc26289 100644
--- a/packages/core/client/src/collection-manager/templates/view.tsx
+++ b/packages/core/client/src/collection-manager/templates/view.tsx
@@ -136,6 +136,6 @@ export const view: ICollectionTemplate = {
},
},
- ...getConfigurableProperties('category'),
+ ...getConfigurableProperties('category', 'description'),
},
};
diff --git a/packages/core/client/src/schema-component/antd/input/Input.tsx b/packages/core/client/src/schema-component/antd/input/Input.tsx
index 52e971a81..1dfcc0e03 100644
--- a/packages/core/client/src/schema-component/antd/input/Input.tsx
+++ b/packages/core/client/src/schema-component/antd/input/Input.tsx
@@ -7,7 +7,7 @@ import { JSONTextAreaProps, Json } from './Json';
import { ReadPretty } from './ReadPretty';
type ComposedInput = React.FC & {
- ReadPretty: React.FC;
+ ReadPretty: React.FC;
TextArea: React.FC;
URL: React.FC;
JSON: React.FC;
diff --git a/packages/plugins/collection-manager/src/server/__tests__/collections.repository.test.ts b/packages/plugins/collection-manager/src/server/__tests__/collections.repository.test.ts
index fd0104264..01bf0bae6 100644
--- a/packages/plugins/collection-manager/src/server/__tests__/collections.repository.test.ts
+++ b/packages/plugins/collection-manager/src/server/__tests__/collections.repository.test.ts
@@ -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('collections')).toBeTruthy();
diff --git a/packages/plugins/collection-manager/src/server/collections/collections.ts b/packages/plugins/collection-manager/src/server/collections/collections.ts
index 7693fd35b..d9946567a 100644
--- a/packages/plugins/collection-manager/src/server/collections/collections.ts
+++ b/packages/plugins/collection-manager/src/server/collections/collections.ts
@@ -44,6 +44,11 @@ export default {
name: 'options',
defaultValue: {},
},
+ {
+ type: 'string',
+ name: 'description',
+ allowNull: true,
+ },
{
type: 'hasMany',
name: 'fields',
diff --git a/packages/plugins/collection-manager/src/server/collections/fields.ts b/packages/plugins/collection-manager/src/server/collections/fields.ts
index feebbe039..54d6390b4 100644
--- a/packages/plugins/collection-manager/src/server/collections/fields.ts
+++ b/packages/plugins/collection-manager/src/server/collections/fields.ts
@@ -37,6 +37,11 @@ export default {
name: 'interface',
allowNull: true,
},
+ {
+ type: 'string',
+ name: 'description',
+ allowNull: true,
+ },
{
type: 'belongsTo',
name: 'collection',
diff --git a/packages/plugins/file-manager/src/client/templates/file.ts b/packages/plugins/file-manager/src/client/templates/file.ts
index ce1253947..77b623fe1 100644
--- a/packages/plugins/file-manager/src/client/templates/file.ts
+++ b/packages/plugins/file-manager/src/client/templates/file.ts
@@ -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',