diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index bfafd55b6..ea620f699 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -14,7 +14,7 @@ import { Modal, Select, Space, - Switch, + Switch } from 'antd'; import classNames from 'classnames'; import { cloneDeep } from 'lodash'; @@ -33,8 +33,9 @@ import { useActionContext, useAPIClient, useCollection, + useCollectionManager, useCompile, - useDesignable, + useDesignable } from '..'; import { useSchemaTemplateManager } from '../schema-templates'; import { useBlockTemplateContext } from '../schema-templates/BlockTemplate'; @@ -135,7 +136,9 @@ export const SchemaSettings: React.FC & SchemaSettingsNeste SchemaSettings.Template = (props) => { const { componentName, collectionName, resourceName } = props; const { t } = useTranslation(); + const { getCollection } = useCollectionManager(); const { dn, setVisible, template, fieldSchema } = useSchemaSettings(); + const compile = useCompile(); const api = useAPIClient(); const { dn: tdn } = useBlockTemplateContext(); const { saveAsTemplate, copyTemplateSchema } = useSchemaTemplateManager(); @@ -165,6 +168,7 @@ SchemaSettings.Template = (props) => { { setVisible(false); + const { title } = getCollection(collectionName); const values = await FormDialog(t('Save as template'), () => { return ( @@ -176,6 +180,7 @@ SchemaSettings.Template = (props) => { name: { title: t('Template name'), required: true, + default: `${compile(title)}_${t(componentName)}`, 'x-decorator': 'FormItem', 'x-component': 'Input', }, @@ -251,6 +256,8 @@ const findBlockTemplateSchema = (fieldSchema) => { SchemaSettings.FormItemTemplate = (props) => { const { insertAdjacentPosition = 'afterBegin', componentName, collectionName, resourceName } = props; const { t } = useTranslation(); + const compile = useCompile(); + const { getCollection } = useCollectionManager(); const { dn, setVisible, template, fieldSchema } = useSchemaSettings(); const api = useAPIClient(); const { saveAsTemplate, copyTemplateSchema } = useSchemaTemplateManager(); @@ -298,8 +305,13 @@ SchemaSettings.FormItemTemplate = (props) => { { setVisible(false); + const { title } = getCollection(collectionName); const gridSchema = findGridSchema(fieldSchema); const values = await FormDialog(t('Save as template'), () => { + const componentTitle = { + FormItem: t('Form'), + ReadPrettyFormItem: t('Details'), + }; return ( { name: { title: t('Template name'), required: true, + default: `${compile(title)}_${componentTitle[componentName] || componentName}`, 'x-decorator': 'FormItem', 'x-component': 'Input', },