feat: collection template summary (#1672)
* feat: collection template description * refactor: improve translation * refactor: improve translation
This commit is contained in:
parent
52329df140
commit
7821af4024
@ -14,6 +14,7 @@ import { useCancelAction } from '../action-hooks';
|
|||||||
import { useCollectionManager } from '../hooks';
|
import { useCollectionManager } from '../hooks';
|
||||||
import * as components from './components';
|
import * as components from './components';
|
||||||
import { templateOptions } from './templates';
|
import { templateOptions } from './templates';
|
||||||
|
import { TemplateSummay } from './components/TemplateSummay';
|
||||||
|
|
||||||
const getSchema = (schema, category, compile): ISchema => {
|
const getSchema = (schema, category, compile): ISchema => {
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
@ -62,7 +63,7 @@ const getSchema = (schema, category, compile): ISchema => {
|
|||||||
properties: {
|
properties: {
|
||||||
summary: {
|
summary: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'FieldSummary',
|
'x-component': 'TemplateSummay',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
schemaKey: schema.name,
|
schemaKey: schema.name,
|
||||||
},
|
},
|
||||||
@ -283,7 +284,7 @@ export const AddCollectionAction = (props) => {
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
<SchemaComponent
|
<SchemaComponent
|
||||||
schema={schema}
|
schema={schema}
|
||||||
components={{ ...components, ArrayTable }}
|
components={{ ...components, ArrayTable, TemplateSummay }}
|
||||||
scope={{
|
scope={{
|
||||||
getContainer,
|
getContainer,
|
||||||
useCancelAction,
|
useCancelAction,
|
||||||
|
@ -15,6 +15,7 @@ import { AddSubFieldAction } from './AddSubFieldAction';
|
|||||||
import { EditSubFieldAction } from './EditSubFieldAction';
|
import { EditSubFieldAction } from './EditSubFieldAction';
|
||||||
import { FieldSummary } from './components/FieldSummary';
|
import { FieldSummary } from './components/FieldSummary';
|
||||||
import { collectionSchema } from './schemas/collections';
|
import { collectionSchema } from './schemas/collections';
|
||||||
|
import {TemplateSummay} from './components/TemplateSummay';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param service
|
* @param service
|
||||||
@ -163,6 +164,7 @@ export const ConfigurationTable = () => {
|
|||||||
AddSubFieldAction,
|
AddSubFieldAction,
|
||||||
EditSubFieldAction,
|
EditSubFieldAction,
|
||||||
FieldSummary,
|
FieldSummary,
|
||||||
|
TemplateSummay,
|
||||||
CollectionFieldsTable,
|
CollectionFieldsTable,
|
||||||
}}
|
}}
|
||||||
scope={{
|
scope={{
|
||||||
|
@ -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 (
|
||||||
|
<div
|
||||||
|
className={css`
|
||||||
|
background: #f6f6f6;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding: 16px;
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<div className={css``}>{t('Collection template')}: <Tag>{compile(schema.title)}</Tag></div>
|
||||||
|
{schema.description ? (
|
||||||
|
<div
|
||||||
|
className={css`
|
||||||
|
margin-top: 8px;
|
||||||
|
color: rgba(0, 0, 0, 0.45);
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
{compile(schema.description)}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
@ -16,6 +16,8 @@ export interface ICollectionTemplate {
|
|||||||
availableFieldInterfaces?: AvailableFieldInterfacesInclude | AvailableFieldInterfacesExclude;
|
availableFieldInterfaces?: AvailableFieldInterfacesInclude | AvailableFieldInterfacesExclude;
|
||||||
/** 是否分割线 */
|
/** 是否分割线 */
|
||||||
divider?: boolean;
|
divider?: boolean;
|
||||||
|
/** 模板描述 */
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AvailableFieldInterfacesInclude {
|
interface AvailableFieldInterfacesInclude {
|
||||||
|
@ -62,6 +62,7 @@ export default {
|
|||||||
"Delete category":"Delete category",
|
"Delete category":"Delete category",
|
||||||
"Edit category":"Edit category",
|
"Edit category":"Edit category",
|
||||||
"Collection category":"Collection category",
|
"Collection category":"Collection category",
|
||||||
|
"Collection template":"Collection template",
|
||||||
"Sort":"Sort",
|
"Sort":"Sort",
|
||||||
"Categories":"Categories",
|
"Categories":"Categories",
|
||||||
"Visible":"Visible",
|
"Visible":"Visible",
|
||||||
@ -179,7 +180,6 @@ export default {
|
|||||||
"Store the last update time of each record": "Store the last update time of each record",
|
"Store the last update time of each record": "Store the last update time of each record",
|
||||||
"More options": "More options",
|
"More options": "More options",
|
||||||
"Records can be sorted": "Records can be sorted",
|
"Records can be sorted": "Records can be sorted",
|
||||||
"Collection template": "Collection template",
|
|
||||||
"Calendar collection": "Calendar collection",
|
"Calendar collection": "Calendar collection",
|
||||||
"General collection": "General collection",
|
"General collection": "General collection",
|
||||||
"Connect to database view":"Connect to database view",
|
"Connect to database view":"Connect to database view",
|
||||||
|
@ -62,6 +62,7 @@ export default {
|
|||||||
"Delete category":"删除分类",
|
"Delete category":"删除分类",
|
||||||
"Edit category":"编辑分类",
|
"Edit category":"编辑分类",
|
||||||
"Collection category":"数据表类别",
|
"Collection category":"数据表类别",
|
||||||
|
"Collection template":"数据表模板",
|
||||||
"Visible":"显示",
|
"Visible":"显示",
|
||||||
"Read only":"只读(禁止编辑)",
|
"Read only":"只读(禁止编辑)",
|
||||||
"Easy reading":"只读(阅读模式)",
|
"Easy reading":"只读(阅读模式)",
|
||||||
@ -188,7 +189,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": "数据表模板",
|
|
||||||
"Calendar collection": "日历数据表",
|
"Calendar collection": "日历数据表",
|
||||||
"General collection": "普通数据表",
|
"General collection": "普通数据表",
|
||||||
"Connect to database view":"连接数据库视图",
|
"Connect to database view":"连接数据库视图",
|
||||||
|
Loading…
Reference in New Issue
Block a user