mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:32:51 +00:00
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 * 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) => {
|
||||
</Dropdown>
|
||||
<SchemaComponent
|
||||
schema={schema}
|
||||
components={{ ...components, ArrayTable }}
|
||||
components={{ ...components, ArrayTable, TemplateSummay }}
|
||||
scope={{
|
||||
getContainer,
|
||||
useCancelAction,
|
||||
|
@ -15,6 +15,7 @@ import { AddSubFieldAction } from './AddSubFieldAction';
|
||||
import { EditSubFieldAction } from './EditSubFieldAction';
|
||||
import { FieldSummary } from './components/FieldSummary';
|
||||
import { collectionSchema } from './schemas/collections';
|
||||
import {TemplateSummay} from './components/TemplateSummay';
|
||||
|
||||
/**
|
||||
* @param service
|
||||
@ -163,6 +164,7 @@ export const ConfigurationTable = () => {
|
||||
AddSubFieldAction,
|
||||
EditSubFieldAction,
|
||||
FieldSummary,
|
||||
TemplateSummay,
|
||||
CollectionFieldsTable,
|
||||
}}
|
||||
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;
|
||||
/** 是否分割线 */
|
||||
divider?: boolean;
|
||||
/** 模板描述 */
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface AvailableFieldInterfacesInclude {
|
||||
|
@ -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",
|
||||
|
@ -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":"连接数据库视图",
|
||||
|
Loading…
Reference in New Issue
Block a user