From 99fdc83daeeaf10ea0817695b51256b94f2a5de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=98=B6?= Date: Sat, 18 Jun 2022 20:01:30 +0800 Subject: [PATCH] feat: add block title (#513) --- packages/core/client/src/locale/zh_CN.ts | 7 +++ .../antd/calendar/Calendar.Designer.tsx | 1 + .../antd/form-v2/Form.Designer.tsx | 3 ++ .../antd/g2plot/G2PlotDesigner.tsx | 1 + .../antd/kanban/Kanban.Designer.tsx | 1 + .../antd/table-v2/TableBlockDesigner.tsx | 3 +- .../client/src/schema-initializer/utils.ts | 2 +- .../src/schema-settings/SchemaSettings.tsx | 47 +++++++++++++++++-- 8 files changed, 60 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index 7260d66cf..5ef35bfc0 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -176,6 +176,13 @@ export default { "Many to one description": "用于创建多对一关系,比如一个城市只能属于一个国家,一个国家可以有多个城市。作为字段存在时,它是一个下拉选择用于选择目标数据表的数据。创建后,会在目标数据表里自动生成一个多对一字段。", "Many to many description": "用于创建多对多关系,比如一个学生会有多个老师,一个老师也会有多个学生。作为字段存在时,它是一个下拉选择用于选择目标数据表的数据。", "Generated automatically if left blank": "留空时,自动生成中间表", + "References fields of associated table": "引用关联表的字段", + "Toggles the subfield mode": "切换子字段模式", + "Selector mode": "选择器模式", + "Subtable mode": "子表格模式", + "Subform mode": "子表单模式", + "Edit block title": "编辑区块标题", + "Block title": "区块标题", "Add filter": "添加筛选条件", "Add filter group": "添加筛选分组", "is": "等于", diff --git a/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx b/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx index 19cffdf99..4d3d5c74d 100644 --- a/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx @@ -36,6 +36,7 @@ export const CalendarDesigner = () => { const defaultResource = fieldSchema?.['x-decorator-props']?.resource; return ( + { return ( {/* */} + { return ( {/* */} + { }); return ( + { const compile = useCompile(); return ( + { const template = useSchemaTemplate(); return ( + { const sortFields = useSortFields(name); const { service } = useTableBlockContext(); const { t } = useTranslation(); - const { dn } = useDesignable(); + const { dn, refresh } = useDesignable(); const defaultFilter = fieldSchema?.['x-decorator-props']?.params?.filter || {}; const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || []; const defaultResource = fieldSchema?.['x-decorator-props']?.resource; @@ -36,6 +36,7 @@ export const TableBlockDesigner = () => { const { dragSort } = field.decoratorProps; return ( + { SchemaSettings.FormItemTemplate = (props) => { const { insertAdjacentPosition = 'afterBegin', componentName, collectionName, resourceName } = props; - console.log('SchemaSettings.Template', props); const { t } = useTranslation(); const { dn, setVisible, template, fieldSchema } = useSchemaSettings(); const api = useAPIClient(); @@ -284,7 +284,6 @@ SchemaSettings.FormItemTemplate = (props) => { onClick={async () => { setVisible(false); const gridSchema = findGridSchema(fieldSchema); - console.log('gridSchema', gridSchema); const values = await FormDialog(t('Save as template'), () => { return ( @@ -586,3 +585,45 @@ SchemaSettings.ModalItem = (props) => { ); }; + +SchemaSettings.BlockTitleItem = () => { + const field = useField(); + const fieldSchema = useFieldSchema(); + const { dn } = useDesignable(); + const { t } = useTranslation(); + + return ( + { + const componentProps = fieldSchema['x-component-props'] || {}; + componentProps.title = title; + fieldSchema['x-component-props'] = componentProps; + field.componentProps.title = title; + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + 'x-component-props': fieldSchema['x-component-props'], + }, + }); + dn.refresh(); + }} + /> + ) + +}