refactor: remove multiple action designer
This commit is contained in:
parent
85ba307506
commit
4ec92ea1e5
@ -1,86 +0,0 @@
|
||||
import { ISchema, useFieldSchema } from '@formily/react';
|
||||
import { SchemaSettingsModalItem, useDesignable } from '@nocobase/client';
|
||||
import { useTranslation } from '../locale';
|
||||
import React from 'react';
|
||||
|
||||
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'],
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import { SchemaSettingsSwitchItem, useDesignable } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { useTranslation } from '../locale';
|
||||
|
||||
// 添加跳转页面选项
|
||||
export const SessionSubmit = () => {
|
||||
const { dn } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
const fieldSchema = useFieldSchema();
|
||||
return (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('Navigate to new page')}
|
||||
checked={!!fieldSchema?.['x-action-settings']?.sessionSubmit}
|
||||
onChange={(value) => {
|
||||
fieldSchema['x-action-settings'].sessionSubmit = value;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-action-settings': {
|
||||
...fieldSchema['x-action-settings'],
|
||||
},
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function SessionUpdate() {
|
||||
const { dn } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
const fieldSchema = useFieldSchema();
|
||||
return (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('更新询问')}
|
||||
checked={!!fieldSchema?.['x-action-settings']?.sessionUpdate}
|
||||
onChange={(value) => {
|
||||
fieldSchema['x-action-settings'].sessionUpdate = value;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-action-settings': {
|
||||
...fieldSchema['x-action-settings'],
|
||||
},
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
@ -11,7 +11,6 @@ import {
|
||||
import { remove } from 'lodash';
|
||||
import { CalendarBlockInitializer } from './schema-initializer/CalendarBlockInitializer';
|
||||
import { MenuDesigner } from './components/ExtendedMenuDesigner';
|
||||
import { SessionSubmit, SessionUpdate } from './components/ExtendedActionDesigner';
|
||||
import { HomePageConfiguration } from './pages/HomePageConfiguration';
|
||||
import { Configuration } from './components/TokenConfiguration';
|
||||
import { InternalPDFViewer } from './schema-components/PDFViewer';
|
||||
@ -35,6 +34,8 @@ import { AssociatedField } from './components/AssociatedField';
|
||||
import { DatePicker } from './schema-components/date-picker';
|
||||
import { SettingBlockInitializer } from './schema-initializer/SettingBlockInitializer';
|
||||
import {
|
||||
SessionSubmit,
|
||||
SessionUpdate,
|
||||
EditFormulaTitleField,
|
||||
IsTablePageSize,
|
||||
useFormulaTitleVisible,
|
||||
@ -42,7 +43,8 @@ import {
|
||||
EditTitle,
|
||||
SetFilterScope,
|
||||
useSetFilterScopeVisible,
|
||||
} from './components/SchemaSettingOptions';
|
||||
AfterSuccess,
|
||||
} from './schema-settings';
|
||||
import { SignatureInput } from './components/SignatureInput';
|
||||
import { RemoteSelect } from './schema-components/remote-select';
|
||||
import { Select } from './schema-components/select/Select';
|
||||
@ -67,7 +69,6 @@ import {
|
||||
customComponentDispatcherSettings,
|
||||
} from './components/CustomComponentDispatcher';
|
||||
import { useFilterBlockActionProps } from './hooks/useFilterBlockActionProps';
|
||||
import { AfterSuccess } from './components/Action.Designer';
|
||||
import { GroupBlockConfigure } from './components/GroupBlockConfigure/GroupBlockConfigure';
|
||||
import { AssociatedFieldInterface } from './interfaces/associated';
|
||||
import { CalcFieldInterface } from './interfaces/calc';
|
||||
|
@ -22,7 +22,6 @@ import {
|
||||
SchemaSettingsDataScope,
|
||||
EditComponent,
|
||||
useFormBlockContext,
|
||||
removeNullCondition,
|
||||
useAPIClient,
|
||||
} from '@nocobase/client';
|
||||
import { ConfigProvider } from 'antd';
|
||||
@ -31,7 +30,7 @@ import { Schema, SchemaOptionsContext, observer, useField, useFieldSchema } from
|
||||
import { FormLayout } from '@formily/antd-v5';
|
||||
import { uid } from '@formily/shared';
|
||||
import { Field } from '@formily/core';
|
||||
import { EditFormulaTitleField, EditTitle, EditTitleField } from '../../components/SchemaSettingOptions';
|
||||
import { EditFormulaTitleField, EditTitle, EditTitleField } from '../../schema-settings';
|
||||
import _ from 'lodash';
|
||||
import { SchemaSettingsRemove } from '../../components/FormFilter/SchemaSettingsRemove';
|
||||
import { useTranslation } from '../../locale';
|
||||
|
@ -1,35 +1,25 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { ISchema, useField, useFieldSchema, useForm } from '@formily/react';
|
||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||
import {
|
||||
SchemaSettingsLinkageRules,
|
||||
SchemaSettingsModalItem,
|
||||
SchemaSettingsSelectItem,
|
||||
SchemaSettingsSwitchItem,
|
||||
css,
|
||||
mergeFilter,
|
||||
removeNullCondition,
|
||||
useBlockRequestContext,
|
||||
useCollection_deprecated,
|
||||
useCollectionManager_deprecated,
|
||||
useCompile,
|
||||
useDesignable,
|
||||
useFieldModeOptions,
|
||||
useFilterFieldProps,
|
||||
useFilterOptions,
|
||||
useFormBlockContext,
|
||||
useFormBlockType,
|
||||
useLinkageCollectionFilterOptions,
|
||||
useLocalVariables,
|
||||
useProps,
|
||||
useRecord,
|
||||
useSchemaTemplateManager,
|
||||
useSortFields,
|
||||
useVariables,
|
||||
} from '@nocobase/client';
|
||||
import _, { get } from 'lodash';
|
||||
import React, { useCallback, useContext, useMemo } from 'react';
|
||||
import _ from 'lodash';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { useTranslation } from '../locale';
|
||||
import { FormFilterScope } from './FormFilter/FormFilterScope';
|
||||
import { FormFilterScope } from '../components/FormFilter/FormFilterScope';
|
||||
|
||||
export const useFormulaTitleOptions = () => {
|
||||
const compile = useCompile();
|
||||
@ -376,3 +366,132 @@ 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 SessionSubmit = () => {
|
||||
const { dn } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
const fieldSchema = useFieldSchema();
|
||||
return (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('Navigate to new page')}
|
||||
checked={!!fieldSchema?.['x-action-settings']?.sessionSubmit}
|
||||
onChange={(value) => {
|
||||
fieldSchema['x-action-settings'].sessionSubmit = value;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-action-settings': {
|
||||
...fieldSchema['x-action-settings'],
|
||||
},
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function SessionUpdate() {
|
||||
const { dn } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
const fieldSchema = useFieldSchema();
|
||||
return (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('更新询问')}
|
||||
checked={!!fieldSchema?.['x-action-settings']?.sessionUpdate}
|
||||
onChange={(value) => {
|
||||
fieldSchema['x-action-settings'].sessionUpdate = value;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-action-settings': {
|
||||
...fieldSchema['x-action-settings'],
|
||||
},
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user