diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx b/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx index 522a0fcaf2..fb27d8a919 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx @@ -19,7 +19,7 @@ import { useCollectionManager_deprecated, useCollection_deprecated } from '../.. import { useFieldComponentName } from '../../../../common/useFieldComponentName'; import { useCollection } from '../../../../data-source'; import { fieldComponentSettingsItem } from '../../../../data-source/commonsSettingsItem'; -import { useDesignable, useValidateSchema } from '../../../../schema-component'; +import { useDesignable, useValidateSchema, useCompile } from '../../../../schema-component'; import { useIsFieldReadPretty, useIsFormReadPretty, @@ -53,6 +53,7 @@ export const fieldSettingsFormItem = new SchemaSettings({ const { dn } = useDesignable(); const field = useField(); const fieldSchema = useFieldSchema(); + const compile = useCompile(); const { getCollectionJoinField } = useCollectionManager_deprecated(); const { getField } = useCollection_deprecated(); const collectionField = @@ -75,16 +76,15 @@ export const fieldSettingsFormItem = new SchemaSettings({ }, } as ISchema, onSubmit({ title }) { - if (title) { - field.title = title; - fieldSchema.title = title; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - title: fieldSchema.title, - }, - }); - } + const result = title.trim() === '' ? collectionField?.uiSchema?.title : title; + field.title = compile(result); + fieldSchema.title = result; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + title: fieldSchema.title, + }, + }); dn.refresh(); }, }; diff --git a/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts b/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts index 15495d082a..838f92c3ab 100644 --- a/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts +++ b/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.ts @@ -17,7 +17,7 @@ import { SchemaSettings } from '../../../../application/schema-settings/SchemaSe import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../../collection-manager'; import { useFieldComponentName } from '../../../../common/useFieldComponentName'; import { fieldComponentSettingsItem } from '../../../../data-source/commonsSettingsItem'; -import { EditOperator, useDesignable, useValidateSchema } from '../../../../schema-component'; +import { EditOperator, useDesignable, useValidateSchema, useCompile } from '../../../../schema-component'; import { SchemaSettingsDefaultValue } from '../../../../schema-settings/SchemaSettingsDefaultValue'; const fieldComponentNameMap = (name: string) => { @@ -49,6 +49,7 @@ export const filterFormItemFieldSettings = new SchemaSettings({ const { t } = useTranslation(); const { dn } = useDesignable(); const field = useField(); + const compile = useCompile(); const fieldSchema = useFieldSchema(); const { getCollectionJoinField } = useCollectionManager_deprecated(); const { getField } = useCollection_deprecated(); @@ -72,16 +73,16 @@ export const filterFormItemFieldSettings = new SchemaSettings({ }, } as ISchema, onSubmit({ title }) { - if (title) { - field.title = title; - fieldSchema.title = title; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - title: fieldSchema.title, - }, - }); - } + const result = title.trim() === '' ? collectionField?.uiSchema?.title : title; + field.title = compile(result); + fieldSchema.title = result; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + title: fieldSchema.title, + }, + }); + dn.refresh(); }, }; diff --git a/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx b/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx index a5700807d2..957d4d09ee 100644 --- a/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx @@ -30,6 +30,7 @@ export const EditTitle = () => { const fieldSchema = useFieldSchema(); const { t } = useTranslation(); const { dn } = useDesignable(); + const compile = useCompile(); const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']); return collectionField ? ( @@ -53,16 +54,16 @@ export const EditTitle = () => { } as ISchema } onSubmit={({ title }) => { - if (title) { - field.title = title; - fieldSchema.title = title; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - title: fieldSchema.title, - }, - }); - } + const result = title.trim() === '' ? collectionField?.uiSchema?.title : title; + field.title = compile(result); + fieldSchema.title = title; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + title: fieldSchema.title, + }, + }); + dn.refresh(); }} /> diff --git a/packages/core/client/src/schema-items/GeneralSchemaItems.tsx b/packages/core/client/src/schema-items/GeneralSchemaItems.tsx index 926a5e8802..6512eb018f 100644 --- a/packages/core/client/src/schema-items/GeneralSchemaItems.tsx +++ b/packages/core/client/src/schema-items/GeneralSchemaItems.tsx @@ -13,7 +13,7 @@ import _ from 'lodash'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { useCollection_deprecated, useCollectionManager_deprecated } from '../collection-manager'; -import { useDesignable } from '../schema-component'; +import { useDesignable, useCompile } from '../schema-component'; import { SchemaSettingsModalItem, SchemaSettingsSwitchItem } from '../schema-settings'; import { getTempFieldState } from '../schema-settings/LinkageRules/bindLinkageRulesToFiled'; @@ -28,6 +28,7 @@ export const GeneralSchemaItems: React.FC<{ const fieldSchema = useFieldSchema(); const { t } = useTranslation(); const { dn, refresh } = useDesignable(); + const compile = useCompile(); const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']); return ( <> @@ -52,16 +53,16 @@ export const GeneralSchemaItems: React.FC<{ } as ISchema } onSubmit={({ title }) => { - if (title) { - field.title = title; - fieldSchema.title = title; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - title: fieldSchema.title, - }, - }); - } + const result = title.trim() === '' ? collectionField?.uiSchema?.title : title; + field.title = compile(result); + fieldSchema.title = title; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + title: fieldSchema.title, + }, + }); + dn.refresh(); }} /> diff --git a/packages/core/client/src/schema-items/GeneralSettings.tsx b/packages/core/client/src/schema-items/GeneralSettings.tsx index 1fe2c2e424..6681f8211d 100644 --- a/packages/core/client/src/schema-items/GeneralSettings.tsx +++ b/packages/core/client/src/schema-items/GeneralSettings.tsx @@ -15,7 +15,7 @@ import { SchemaSettingOptions } from '../application'; import { useSchemaToolbar } from '../application/schema-toolbar'; import { useCollection_deprecated, useCollectionManager_deprecated } from '../collection-manager'; import { SchemaSettingsLinkageRules } from '../schema-settings'; -import { useIsFieldReadPretty } from '../schema-component'; +import { useIsFieldReadPretty, useCompile } from '../schema-component'; import { useCollection } from '../data-source'; export const generalSettingsItems: SchemaSettingOptions['items'] = [ @@ -25,6 +25,7 @@ export const generalSettingsItems: SchemaSettingOptions['items'] = [ useComponentProps() { const { t } = useTranslation(); const { dn } = useDesignable(); + const compile = useCompile(); const field = useField(); const fieldSchema = useFieldSchema(); const { getCollectionJoinField } = useCollectionManager_deprecated(); @@ -49,16 +50,16 @@ export const generalSettingsItems: SchemaSettingOptions['items'] = [ }, } as ISchema, onSubmit({ title }) { - if (title) { - field.title = title; - fieldSchema.title = title; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - title: fieldSchema.title, - }, - }); - } + const result = title.trim() === '' ? collectionField?.uiSchema?.title : title; + field.title = compile(result); + fieldSchema.title = title; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + title: fieldSchema.title, + }, + }); + dn.refresh(); }, }; diff --git a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/bulkEditFormItemSettings.ts b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/bulkEditFormItemSettings.ts index 87069a771f..b37491008b 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/bulkEditFormItemSettings.ts +++ b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/bulkEditFormItemSettings.ts @@ -22,6 +22,7 @@ import { useValidateSchema, fieldComponentSettingsItem, EditValidationRules, + useCompile, } from '@nocobase/client'; import _ from 'lodash'; import { useTranslation } from 'react-i18next'; @@ -46,6 +47,7 @@ export const bulkEditFormItemSettings = new SchemaSettings({ type: 'modal', useComponentProps() { const { t } = useTranslation(); + const compile = useCompile(); const { dn } = useDesignable(); const field = useField(); const fieldSchema = useFieldSchema(); @@ -70,16 +72,16 @@ export const bulkEditFormItemSettings = new SchemaSettings({ }, }, onSubmit({ title }) { - if (title) { - field.title = title; - fieldSchema.title = title; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - title: fieldSchema.title, - }, - }); - } + const result = title.trim() === '' ? collectionField?.uiSchema?.title : title; + field.title = compile(result); + fieldSchema.title = title; + dn.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + title: fieldSchema.title, + }, + }); + dn.refresh(); }, };