refactor: remove after success
This commit is contained in:
parent
eddb3230c6
commit
e07ee53db7
@ -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() {
|
||||
|
@ -15,7 +15,7 @@ export const CreateSubmitActionInitializer: React.FC = (props) => {
|
||||
'x-action-settings': {
|
||||
assignedValues: {},
|
||||
triggerWorkflows: [],
|
||||
sessionSubmit: false,
|
||||
pageMode: false,
|
||||
},
|
||||
};
|
||||
return <ActionInitializer {...props} schema={schema} />;
|
||||
|
@ -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);
|
||||
|
@ -469,88 +469,6 @@ export const SetFilterScope = (props) => {
|
||||
return <SchemaSettingsModalItem title={t('Custom filter')} width={770} schema={schema} onSubmit={onSubmit} />;
|
||||
};
|
||||
|
||||
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 (
|
||||
<SchemaSettingsModalItem
|
||||
title={t('After successful submission')}
|
||||
initialValues={fieldSchema?.['x-action-settings']?.['onSuccess']}
|
||||
schema={{ ...schema } as ISchema}
|
||||
onSubmit={(onSuccess) => {
|
||||
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 (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('Navigate to new page')}
|
||||
checked={!!fieldSchema?.['x-action-settings']?.sessionSubmit}
|
||||
checked={!!fieldSchema?.['x-action-settings']?.pageMode}
|
||||
onChange={(value) => {
|
||||
fieldSchema['x-action-settings'].sessionSubmit = value;
|
||||
fieldSchema['x-action-settings'].pageMode = value;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
|
Loading…
Reference in New Issue
Block a user