mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
feat: add a secondary confirmation function to the direct execution o… (#3161)
* feat: add a secondary confirmation function to the direct execution of the move operation button * feat: add a secondary confirmation function to the direct execution of the move operation button * fix: fix the problem of uncontrolled confirm * fix: copywriting repair --------- Co-authored-by: zhangboya3 <zhangboya3@xiaomi.com> Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
5a55987033
commit
9b1c02b63c
@ -830,6 +830,9 @@
|
||||
"Please use a valid SELECT or WITH AS statement": "请使用有效的 SELECT 或 WITH AS 语句",
|
||||
"Please confirm the SQL statement first": "请先确认 SQL 语句",
|
||||
"Automatically drop objects that depend on the collection (such as views), and in turn all objects that depend on those objects": "自动删除依赖于该表的对象,以及依赖这些对象的对象",
|
||||
"Second confirmation": "二次确认",
|
||||
"Perform the {{title}}": "执行{{title}}",
|
||||
"Are you sure you want to perform the {{title}} action?": "你确定执行{{title}}操作吗?",
|
||||
"Sign in with another account": "登录其他账号",
|
||||
"Return to the main application": "返回主应用",
|
||||
"Permission denied": "没有权限"
|
||||
|
@ -28,6 +28,7 @@ import {
|
||||
import { DefaultValueProvider } from '../../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
||||
import { useLinkageAction } from './hooks';
|
||||
import { requestSettingsSchema } from './utils';
|
||||
import { Field } from '@formily/core';
|
||||
|
||||
const Tree = connect(
|
||||
AntdTree,
|
||||
@ -695,6 +696,33 @@ export const actionSettingsItems: SchemaSettingOptions['items'] = [
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'updateMode',
|
||||
Component: UpdateMode,
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const isUpdateModePopupAction = ['customize:bulkUpdate', 'customize:bulkEdit'].includes(
|
||||
fieldSchema['x-action'],
|
||||
);
|
||||
return isUpdateModePopupAction;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'secondConFirm',
|
||||
Component: SecondConFirm,
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const isPopupAction = [
|
||||
'create',
|
||||
'update',
|
||||
'view',
|
||||
'customize:popup',
|
||||
'duplicate',
|
||||
'customize:create',
|
||||
].includes(fieldSchema['x-action'] || '');
|
||||
return !isPopupAction;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'assignFieldValues',
|
||||
Component: AssignedFieldValues,
|
||||
@ -769,7 +797,42 @@ export const actionSettingsItems: SchemaSettingOptions['items'] = [
|
||||
],
|
||||
},
|
||||
];
|
||||
function SecondConFirm() {
|
||||
const { dn } = useDesignable();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { t } = useTranslation();
|
||||
const field = useField<Field>();
|
||||
|
||||
return (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('Second confirmation')}
|
||||
checked={!!fieldSchema?.['x-component-props']?.confirm?.content}
|
||||
onChange={(value) => {
|
||||
if (!fieldSchema['x-component-props']) {
|
||||
fieldSchema['x-component-props'] = {};
|
||||
}
|
||||
if (value) {
|
||||
fieldSchema['x-component-props'].confirm = value
|
||||
? {
|
||||
title: 'Perform the {{title}}',
|
||||
content: 'Are you sure you want to perform the {{title}} action?',
|
||||
}
|
||||
: {};
|
||||
} else {
|
||||
fieldSchema['x-component-props'].confirm = {};
|
||||
}
|
||||
field.componentProps.confirm = { ...fieldSchema['x-component-props']?.confirm };
|
||||
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-component-props': { ...fieldSchema['x-component-props'] },
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export const actionSettings = new SchemaSettings({
|
||||
name: 'ActionSettings',
|
||||
items: actionSettingsItems,
|
||||
|
@ -65,7 +65,6 @@ export const Action: ComposedAction = observer(
|
||||
const variables = useVariables();
|
||||
const localVariables = useLocalVariables({ currentForm: { values: record } as any });
|
||||
const { getAriaLabel } = useGetAriaLabelOfAction(title);
|
||||
|
||||
let actionTitle = title || compile(fieldSchema.title);
|
||||
actionTitle = lodash.isString(actionTitle) ? t(actionTitle) : actionTitle;
|
||||
|
||||
@ -106,9 +105,10 @@ export const Action: ComposedAction = observer(
|
||||
setVisible(true);
|
||||
run();
|
||||
};
|
||||
if (confirm) {
|
||||
if (confirm?.content) {
|
||||
modal.confirm({
|
||||
...confirm,
|
||||
title: t(confirm.title, { title: actionTitle }),
|
||||
content: t(confirm.content, { title: actionTitle }),
|
||||
onOk,
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user