From 7821af40243778a7f209fe1269a8f85efc345649 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sat, 8 Apr 2023 14:18:20 +0800 Subject: [PATCH] feat: collection template summary (#1672) * feat: collection template description * refactor: improve translation * refactor: improve translation --- .../Configuration/AddCollectionAction.tsx | 5 ++- .../Configuration/ConfigurationTable.tsx | 2 + .../components/TemplateSummay.tsx | 39 +++++++++++++++++++ .../src/collection-manager/templates/types.ts | 2 + packages/core/client/src/locale/en_US.ts | 2 +- packages/core/client/src/locale/zh_CN.ts | 2 +- 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 packages/core/client/src/collection-manager/Configuration/components/TemplateSummay.tsx diff --git a/packages/core/client/src/collection-manager/Configuration/AddCollectionAction.tsx b/packages/core/client/src/collection-manager/Configuration/AddCollectionAction.tsx index 0e238b19f0..4ed0b29e4f 100644 --- a/packages/core/client/src/collection-manager/Configuration/AddCollectionAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/AddCollectionAction.tsx @@ -14,6 +14,7 @@ import { useCancelAction } from '../action-hooks'; import { useCollectionManager } from '../hooks'; import * as components from './components'; import { templateOptions } from './templates'; +import { TemplateSummay } from './components/TemplateSummay'; const getSchema = (schema, category, compile): ISchema => { if (!schema) { @@ -62,7 +63,7 @@ const getSchema = (schema, category, compile): ISchema => { properties: { summary: { type: 'void', - 'x-component': 'FieldSummary', + 'x-component': 'TemplateSummay', 'x-component-props': { schemaKey: schema.name, }, @@ -283,7 +284,7 @@ export const AddCollectionAction = (props) => { { AddSubFieldAction, EditSubFieldAction, FieldSummary, + TemplateSummay, CollectionFieldsTable, }} scope={{ diff --git a/packages/core/client/src/collection-manager/Configuration/components/TemplateSummay.tsx b/packages/core/client/src/collection-manager/Configuration/components/TemplateSummay.tsx new file mode 100644 index 0000000000..46b9c998b4 --- /dev/null +++ b/packages/core/client/src/collection-manager/Configuration/components/TemplateSummay.tsx @@ -0,0 +1,39 @@ +import { css } from '@emotion/css'; +import { observer } from '@formily/react'; +import { Tag } from 'antd'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { useCompile } from '../../../schema-component'; +import { useCollectionManager } from '../../hooks'; + +export const TemplateSummay = observer((props: any) => { + const { schemaKey } = props; + const { getTemplate } = useCollectionManager(); + const compile = useCompile(); + const { t } = useTranslation(); + const schema = getTemplate(schemaKey); + + if (!schema) return null; + + return ( +
+
{t('Collection template')}: {compile(schema.title)}
+ {schema.description ? ( +
+ {compile(schema.description)} +
+ ) : null} +
+ ); +}); diff --git a/packages/core/client/src/collection-manager/templates/types.ts b/packages/core/client/src/collection-manager/templates/types.ts index 3d7753cc45..a34bab1211 100644 --- a/packages/core/client/src/collection-manager/templates/types.ts +++ b/packages/core/client/src/collection-manager/templates/types.ts @@ -16,6 +16,8 @@ export interface ICollectionTemplate { availableFieldInterfaces?: AvailableFieldInterfacesInclude | AvailableFieldInterfacesExclude; /** 是否分割线 */ divider?: boolean; + /** 模板描述 */ + description?: string; } interface AvailableFieldInterfacesInclude { diff --git a/packages/core/client/src/locale/en_US.ts b/packages/core/client/src/locale/en_US.ts index a1cbb36f64..3fb6d78897 100644 --- a/packages/core/client/src/locale/en_US.ts +++ b/packages/core/client/src/locale/en_US.ts @@ -62,6 +62,7 @@ export default { "Delete category":"Delete category", "Edit category":"Edit category", "Collection category":"Collection category", + "Collection template":"Collection template", "Sort":"Sort", "Categories":"Categories", "Visible":"Visible", @@ -179,7 +180,6 @@ export default { "Store the last update time of each record": "Store the last update time of each record", "More options": "More options", "Records can be sorted": "Records can be sorted", - "Collection template": "Collection template", "Calendar collection": "Calendar collection", "General collection": "General collection", "Connect to database view":"Connect to database view", diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index 7b23cef82f..3df62a086f 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -62,6 +62,7 @@ export default { "Delete category":"删除分类", "Edit category":"编辑分类", "Collection category":"数据表类别", + "Collection template":"数据表模板", "Visible":"显示", "Read only":"只读(禁止编辑)", "Easy reading":"只读(阅读模式)", @@ -188,7 +189,6 @@ export default { "Store the last update time of each record": "记录最后更新时间", "More options": "更多选项", "Records can be sorted": "可以对行记录进行排序", - "Collection template": "数据表模板", "Calendar collection": "日历数据表", "General collection": "普通数据表", "Connect to database view":"连接数据库视图",