diff --git a/packages/plugins/@hera/plugin-core/src/client/index.tsx b/packages/plugins/@hera/plugin-core/src/client/index.tsx index fdf8373e8..5084d7a95 100644 --- a/packages/plugins/@hera/plugin-core/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/index.tsx @@ -1,17 +1,10 @@ import React from 'react'; -import { - Menu, - Plugin, - RemoteSchemaTemplateManagerProvider, - EditTitleField, - SchemaSettingOptions, - useCollection, -} from '@nocobase/client'; +import { Menu, Plugin, RemoteSchemaTemplateManagerProvider, EditTitleField, useCollection } from '@nocobase/client'; import { remove } from 'lodash'; import { useFieldSchema } from '@formily/react'; import { isValid } from '@formily/shared'; import { autorun } from '@formily/reactive'; -import { Locale, lang, tval } from './locale'; +import { Locale, tval } from './locale'; import { PageModeSetting, EditFormulaTitleField, @@ -21,7 +14,6 @@ import { EditTitle, SetFilterScope, useSetFilterScopeVisible, - AfterSuccess, FilterVariableInput, EditDefaultValue, } from './schema-settings'; @@ -131,21 +123,13 @@ export class PluginCoreClient extends Plugin { }; }, }); - this.app.schemaSettingsManager.addItem('actionSettings:submit', '', { + this.app.schemaSettingsManager.addItem('actionSettings:submit', 'pageMode', { Component: PageModeSetting, useVisible() { const fieldSchema = useFieldSchema(); - return isValid(fieldSchema?.['x-action-settings']?.sessionSubmit); + return isValid(fieldSchema?.['x-action-settings']?.pageMode); }, }); - const SchemaSettingOptionItems = this.schemaSettingsManager - .get('ActionSettings') - .items.filter((item) => item.name === 'Customize')[0].children; - SchemaSettingOptionItems.forEach((item) => { - if (item.name === 'afterSuccess') { - (item as SchemaSettingOptions).Component = AfterSuccess; - } - }); // 预览区块需要提前加进来,没法放在 afterload 中,这块后面需要重构 const previewBlockItem = { @@ -169,9 +153,7 @@ export class PluginCoreClient extends Plugin { this.app.addComponents({ AdminLayout, - AfterSuccess, AssociatedField, - RemoteSelect, AutoComplete, CalcResult, CreateSubmitActionInitializer, @@ -202,13 +184,14 @@ export class PluginCoreClient extends Plugin { PDFViewerProvider, PDFViwer: InternalPDFViewer, PageLayout, + RemoteSelect, Select, SettingBlock: SettingBlockInitializer, - SignatureInput, SheetBlock, SheetBlockInitializer, SheetBlockProvider, SheetBlockToolbar, + SignatureInput, }); } @@ -300,13 +283,13 @@ export class PluginCoreClient extends Plugin { async afterLoad() { // log for debug + await this.registerSchemaInitializer(); if (process.env.NODE_ENV !== 'production') { console.info('current components', this.app.components); console.info('current schemaSettings', this.app.schemaSettingsManager.getAll()); console.info('current schemaInitializer', this.app.schemaInitializerManager.getAll()); console.info('current providers', this.app.providers); } - await this.registerSchemaInitializer(); } async load() { diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/CreateSubmitActionInitializer.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/CreateSubmitActionInitializer.tsx index 59ff3bd30..3b8ed658f 100644 --- a/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/CreateSubmitActionInitializer.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/CreateSubmitActionInitializer.tsx @@ -15,7 +15,7 @@ export const CreateSubmitActionInitializer: React.FC = (props) => { 'x-action-settings': { assignedValues: {}, triggerWorkflows: [], - sessionSubmit: false, + pageMode: false, }, }; return ; diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/hooks/useCreateActionProps.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/hooks/useCreateActionProps.tsx index 2ba45f999..752ca0e02 100644 --- a/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/hooks/useCreateActionProps.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/schema-initializer/actions/hooks/useCreateActionProps.tsx @@ -102,7 +102,7 @@ export const useCreateActionProps = () => { overwriteValues, skipValidator, triggerWorkflows, - sessionSubmit, + pageMode, } = actionSchema?.['x-action-settings'] ?? {}; const addChild = fieldSchema?.['x-component-props']?.addChild; const assignedValues = {}; @@ -165,7 +165,7 @@ export const useCreateActionProps = () => { actionField.data.data = data; __parent?.service?.refresh?.(); if (!onSuccess?.successMessage) { - if (sessionSubmit) { + if (pageMode) { message.success(t('Saved successfully')); if (dn.designable) { insert(viewerSchema); diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-settings/index.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-settings/index.tsx index 12c9c4eb7..5cdef5392 100644 --- a/packages/plugins/@hera/plugin-core/src/client/schema-settings/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/schema-settings/index.tsx @@ -469,88 +469,6 @@ export const SetFilterScope = (props) => { return ; }; -export function AfterSuccess() { - const { dn } = useDesignable(); - const { t } = useTranslation(); - const fieldSchema = useFieldSchema(); - const component = fieldSchema.parent.parent['x-component']; - const schema = { - type: 'object', - title: t('After successful submission'), - properties: { - successMessage: { - title: t('Popup message'), - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - 'x-component-props': {}, - }, - dataClear: { - title: t('Clear data method'), - enum: [ - { label: t('Automatic clear'), value: false }, - { label: t('Manually clear'), value: true }, - ], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': {}, - }, - manualClose: { - title: t('Popup close method'), - enum: [ - { label: t('Automatic close'), value: false }, - { label: t('Manually close'), value: true }, - ], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': {}, - }, - redirecting: { - title: t('Then'), - enum: [ - { label: t('Stay on current page'), value: false }, - { label: t('Redirect to'), value: true }, - ], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': {}, - 'x-reactions': { - target: 'redirectTo', - fulfill: { - state: { - visible: '{{!!$self.value}}', - }, - }, - }, - }, - redirectTo: { - title: t('Link'), - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': {}, - }, - }, - }; - if (!(component as string).includes('Form')) { - delete schema.properties.dataClear; - } - return ( - { - fieldSchema['x-action-settings']['onSuccess'] = onSuccess; - dn.emit('patch', { - schema: { - ['x-uid']: fieldSchema['x-uid'], - 'x-action-settings': fieldSchema['x-action-settings'], - }, - }); - }} - /> - ); -} - // 添加跳转页面选项 export const PageModeSetting = () => { const { dn } = useDesignable(); @@ -559,9 +477,9 @@ export const PageModeSetting = () => { return ( { - fieldSchema['x-action-settings'].sessionSubmit = value; + fieldSchema['x-action-settings'].pageMode = value; dn.emit('patch', { schema: { ['x-uid']: fieldSchema['x-uid'],