mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:47:10 +00:00
feat: default value of block template title
This commit is contained in:
parent
43e52843fa
commit
780f2d556e
@ -14,7 +14,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
@ -33,8 +33,9 @@ import {
|
|||||||
useActionContext,
|
useActionContext,
|
||||||
useAPIClient,
|
useAPIClient,
|
||||||
useCollection,
|
useCollection,
|
||||||
|
useCollectionManager,
|
||||||
useCompile,
|
useCompile,
|
||||||
useDesignable,
|
useDesignable
|
||||||
} from '..';
|
} from '..';
|
||||||
import { useSchemaTemplateManager } from '../schema-templates';
|
import { useSchemaTemplateManager } from '../schema-templates';
|
||||||
import { useBlockTemplateContext } from '../schema-templates/BlockTemplate';
|
import { useBlockTemplateContext } from '../schema-templates/BlockTemplate';
|
||||||
@ -135,7 +136,9 @@ export const SchemaSettings: React.FC<SchemaSettingsProps> & SchemaSettingsNeste
|
|||||||
SchemaSettings.Template = (props) => {
|
SchemaSettings.Template = (props) => {
|
||||||
const { componentName, collectionName, resourceName } = props;
|
const { componentName, collectionName, resourceName } = props;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { getCollection } = useCollectionManager();
|
||||||
const { dn, setVisible, template, fieldSchema } = useSchemaSettings();
|
const { dn, setVisible, template, fieldSchema } = useSchemaSettings();
|
||||||
|
const compile = useCompile();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const { dn: tdn } = useBlockTemplateContext();
|
const { dn: tdn } = useBlockTemplateContext();
|
||||||
const { saveAsTemplate, copyTemplateSchema } = useSchemaTemplateManager();
|
const { saveAsTemplate, copyTemplateSchema } = useSchemaTemplateManager();
|
||||||
@ -165,6 +168,7 @@ SchemaSettings.Template = (props) => {
|
|||||||
<SchemaSettings.Item
|
<SchemaSettings.Item
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
const { title } = getCollection(collectionName);
|
||||||
const values = await FormDialog(t('Save as template'), () => {
|
const values = await FormDialog(t('Save as template'), () => {
|
||||||
return (
|
return (
|
||||||
<FormLayout layout={'vertical'}>
|
<FormLayout layout={'vertical'}>
|
||||||
@ -176,6 +180,7 @@ SchemaSettings.Template = (props) => {
|
|||||||
name: {
|
name: {
|
||||||
title: t('Template name'),
|
title: t('Template name'),
|
||||||
required: true,
|
required: true,
|
||||||
|
default: `${compile(title)}_${t(componentName)}`,
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
},
|
},
|
||||||
@ -251,6 +256,8 @@ const findBlockTemplateSchema = (fieldSchema) => {
|
|||||||
SchemaSettings.FormItemTemplate = (props) => {
|
SchemaSettings.FormItemTemplate = (props) => {
|
||||||
const { insertAdjacentPosition = 'afterBegin', componentName, collectionName, resourceName } = props;
|
const { insertAdjacentPosition = 'afterBegin', componentName, collectionName, resourceName } = props;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const compile = useCompile();
|
||||||
|
const { getCollection } = useCollectionManager();
|
||||||
const { dn, setVisible, template, fieldSchema } = useSchemaSettings();
|
const { dn, setVisible, template, fieldSchema } = useSchemaSettings();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const { saveAsTemplate, copyTemplateSchema } = useSchemaTemplateManager();
|
const { saveAsTemplate, copyTemplateSchema } = useSchemaTemplateManager();
|
||||||
@ -298,8 +305,13 @@ SchemaSettings.FormItemTemplate = (props) => {
|
|||||||
<SchemaSettings.Item
|
<SchemaSettings.Item
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
const { title } = getCollection(collectionName);
|
||||||
const gridSchema = findGridSchema(fieldSchema);
|
const gridSchema = findGridSchema(fieldSchema);
|
||||||
const values = await FormDialog(t('Save as template'), () => {
|
const values = await FormDialog(t('Save as template'), () => {
|
||||||
|
const componentTitle = {
|
||||||
|
FormItem: t('Form'),
|
||||||
|
ReadPrettyFormItem: t('Details'),
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<FormLayout layout={'vertical'}>
|
<FormLayout layout={'vertical'}>
|
||||||
<SchemaComponent
|
<SchemaComponent
|
||||||
@ -310,6 +322,7 @@ SchemaSettings.FormItemTemplate = (props) => {
|
|||||||
name: {
|
name: {
|
||||||
title: t('Template name'),
|
title: t('Template name'),
|
||||||
required: true,
|
required: true,
|
||||||
|
default: `${compile(title)}_${componentTitle[componentName] || componentName}`,
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user