mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
feat: action support refreshDataBlockRequest configuration (#3882)
* feat: action support refreshDataBlockRequest configuration * feat: refreshDataBlockRequest * fix: block templates * fix: bug * fix: bug * refactor: submitted * fix: bug * fix: bug * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * refactor: refreshDataBlockRequest * fix: bug * fix: bug * fix: bug * fix: bug --------- Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
fcd2b766cf
commit
6e5a2c81b3
@ -189,7 +189,7 @@ export const useCreateActionProps = () => {
|
||||
const record = useCollectionRecord();
|
||||
const form = useForm();
|
||||
const { field, resource, __parent } = useBlockRequestContext();
|
||||
const { setVisible } = useActionContext();
|
||||
const { setVisible, setSubmitted, setFormValueChanged } = useActionContext();
|
||||
const navigate = useNavigate();
|
||||
const actionSchema = useFieldSchema();
|
||||
const actionField = useField();
|
||||
@ -202,8 +202,6 @@ export const useCreateActionProps = () => {
|
||||
const filterKeys = actionField.componentProps.filterKeys?.checked || [];
|
||||
const dataLoadingMode = useDataLoadingMode();
|
||||
|
||||
console.log('dataLoadingMode', dataLoadingMode);
|
||||
|
||||
return {
|
||||
async onClick() {
|
||||
const { onSuccess, skipValidator, triggerWorkflows } = actionSchema?.['x-action-settings'] ?? {};
|
||||
@ -226,9 +224,11 @@ export const useCreateActionProps = () => {
|
||||
updateAssociationValues,
|
||||
});
|
||||
setVisible?.(false);
|
||||
setSubmitted?.(true);
|
||||
setFormValueChanged?.(false);
|
||||
actionField.data.loading = false;
|
||||
actionField.data.data = data;
|
||||
__parent?.service?.refresh?.();
|
||||
// __parent?.service?.refresh?.();
|
||||
if (!onSuccess?.successMessage) {
|
||||
message.success(t('Saved successfully'));
|
||||
await resetFormCorrectly(form);
|
||||
@ -269,7 +269,7 @@ export const useCreateActionProps = () => {
|
||||
export const useAssociationCreateActionProps = () => {
|
||||
const form = useForm();
|
||||
const { field, resource, __parent } = useBlockRequestContext();
|
||||
const { setVisible, fieldSchema } = useActionContext();
|
||||
const { setVisible, fieldSchema, setSubmitted } = useActionContext();
|
||||
const actionSchema = useFieldSchema();
|
||||
const actionField = useField();
|
||||
const { fields, getField, getTreeParentField, name } = useCollection_deprecated();
|
||||
@ -352,6 +352,7 @@ export const useAssociationCreateActionProps = () => {
|
||||
actionField.data.data = data;
|
||||
__parent?.service?.refresh?.();
|
||||
setVisible?.(false);
|
||||
setSubmitted?.(true);
|
||||
if (!onSuccess?.successMessage) {
|
||||
return;
|
||||
}
|
||||
@ -517,7 +518,7 @@ export const useCustomizeUpdateActionProps = () => {
|
||||
const { name, getField } = useCollection_deprecated();
|
||||
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e?, callBack?) {
|
||||
const {
|
||||
assignedValues: originalAssignedValues = {},
|
||||
onSuccess,
|
||||
@ -558,7 +559,10 @@ export const useCustomizeUpdateActionProps = () => {
|
||||
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
|
||||
: undefined,
|
||||
});
|
||||
service?.refresh?.();
|
||||
// service?.refresh?.();
|
||||
if (callBack) {
|
||||
callBack?.();
|
||||
}
|
||||
if (!(resource instanceof TableFieldResource)) {
|
||||
__parent?.service?.refresh?.();
|
||||
}
|
||||
@ -670,7 +674,7 @@ export const useCustomizeBulkUpdateActionProps = () => {
|
||||
} finally {
|
||||
actionField.data.loading = false;
|
||||
}
|
||||
service?.refresh?.();
|
||||
// service?.refresh?.();
|
||||
if (!(resource instanceof TableFieldResource)) {
|
||||
__parent?.service?.refresh?.();
|
||||
}
|
||||
@ -805,7 +809,7 @@ export const useUpdateActionProps = () => {
|
||||
const form = useForm();
|
||||
const filterByTk = useFilterByTk();
|
||||
const { field, resource, __parent } = useBlockRequestContext();
|
||||
const { setVisible } = useActionContext();
|
||||
const { setVisible, setSubmitted, setFormValueChanged } = useActionContext();
|
||||
const actionSchema = useFieldSchema();
|
||||
const navigate = useNavigate();
|
||||
const { fields, getField, name } = useCollection_deprecated();
|
||||
@ -881,8 +885,10 @@ export const useUpdateActionProps = () => {
|
||||
: undefined,
|
||||
});
|
||||
actionField.data.loading = false;
|
||||
__parent?.service?.refresh?.();
|
||||
// __parent?.service?.refresh?.();
|
||||
setVisible?.(false);
|
||||
setSubmitted?.(true);
|
||||
setFormValueChanged?.(false);
|
||||
if (!onSuccess?.successMessage) {
|
||||
return;
|
||||
}
|
||||
@ -920,11 +926,11 @@ export const useUpdateActionProps = () => {
|
||||
export const useDestroyActionProps = () => {
|
||||
const filterByTk = useFilterByTk();
|
||||
const { resource, service, block, __parent } = useBlockRequestContext();
|
||||
const { setVisible } = useActionContext();
|
||||
const { setVisible, setSubmitted } = useActionContext();
|
||||
const data = useParamsFromRecord();
|
||||
const actionSchema = useFieldSchema();
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e?, callBack?) {
|
||||
const { triggerWorkflows } = actionSchema?.['x-action-settings'] ?? {};
|
||||
await resource.destroy({
|
||||
filterByTk,
|
||||
@ -941,13 +947,18 @@ export const useDestroyActionProps = () => {
|
||||
...service?.params?.[0],
|
||||
page: page - 1,
|
||||
});
|
||||
} else {
|
||||
service?.refresh?.();
|
||||
}
|
||||
|
||||
if (callBack) {
|
||||
callBack?.();
|
||||
}
|
||||
// else {
|
||||
// service?.refresh?.();
|
||||
// }
|
||||
setSubmitted?.(true);
|
||||
if (block && block !== 'TableField') {
|
||||
__parent?.service?.refresh?.();
|
||||
setVisible?.(false);
|
||||
setSubmitted?.(true);
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -969,9 +980,9 @@ export const useRemoveActionProps = (associationName) => {
|
||||
export const useDisassociateActionProps = () => {
|
||||
const filterByTk = useFilterByTk();
|
||||
const { resource, service, block, __parent } = useBlockRequestContext();
|
||||
const { setVisible } = useActionContext();
|
||||
const { setVisible, setSubmitted, setFormValueChanged } = useActionContext();
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e?, callBack?) {
|
||||
await resource.remove({
|
||||
values: [filterByTk],
|
||||
});
|
||||
@ -983,12 +994,15 @@ export const useDisassociateActionProps = () => {
|
||||
page: page - 1,
|
||||
});
|
||||
} else {
|
||||
service?.refresh?.();
|
||||
if (callBack) {
|
||||
callBack?.();
|
||||
}
|
||||
|
||||
}
|
||||
setSubmitted?.(true);
|
||||
if (block && block !== 'TableField') {
|
||||
__parent?.service?.refresh?.();
|
||||
setVisible?.(false);
|
||||
setFormValueChanged?.(false);
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -1018,8 +1032,9 @@ export const useDetailPrintActionProps = () => {
|
||||
export const useBulkDestroyActionProps = () => {
|
||||
const { field } = useBlockRequestContext();
|
||||
const { resource, service } = useBlockRequestContext();
|
||||
const { setSubmitted } = useActionContext();
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e?, callBack?) {
|
||||
if (!field?.data?.selectedRowKeys?.length) {
|
||||
return;
|
||||
}
|
||||
@ -1032,7 +1047,11 @@ export const useBulkDestroyActionProps = () => {
|
||||
if (currentPage === totalPage) {
|
||||
service.params[0].page = currentPage - 1;
|
||||
}
|
||||
service?.refresh?.();
|
||||
if (callBack) {
|
||||
callBack?.();
|
||||
}
|
||||
setSubmitted?.(true);
|
||||
// service?.refresh?.();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
@ -916,9 +916,11 @@
|
||||
"Separator": "分隔符",
|
||||
"Prefix": "前缀",
|
||||
"Suffix": "后缀",
|
||||
"Multiply by":"乘以",
|
||||
"Divide by":"除以",
|
||||
"Scientifix notation":"科学计数法",
|
||||
"Normal":"常规",
|
||||
"Automatically generate default values":"随机生成默认值"
|
||||
"Multiply by": "乘以",
|
||||
"Divide by": "除以",
|
||||
"Scientifix notation": "科学计数法",
|
||||
"Normal": "常规",
|
||||
"Automatically generate default values": "随机生成默认值",
|
||||
"Refresh data on close": "关闭后刷新数据",
|
||||
"Refresh data on action": "执行后刷新数据"
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { useSchemaToolbar } from '../../../application';
|
||||
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
||||
import { ButtonEditor, RemoveButton, SecondConFirm } from '../../../schema-component/antd/action/Action.Designer';
|
||||
import {
|
||||
ButtonEditor,
|
||||
RemoveButton,
|
||||
SecondConFirm,
|
||||
RefreshDataBlockRequest,
|
||||
} from '../../../schema-component/antd/action/Action.Designer';
|
||||
|
||||
export const bulkDeleteActionSettings = new SchemaSettings({
|
||||
name: 'actionSettings:bulkDelete',
|
||||
@ -17,6 +22,15 @@ export const bulkDeleteActionSettings = new SchemaSettings({
|
||||
name: 'secondConFirm',
|
||||
Component: SecondConFirm,
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'remove',
|
||||
sort: 100,
|
||||
|
@ -16,6 +16,7 @@ export const DestroyActionInitializer = (props) => {
|
||||
title: "{{t('Delete record')}}",
|
||||
content: "{{t('Are you sure you want to delete it?')}}",
|
||||
},
|
||||
refreshDataBlockRequest: true,
|
||||
},
|
||||
'x-action-settings': {
|
||||
triggerWorkflows: [],
|
||||
|
@ -1,7 +1,11 @@
|
||||
import { useSchemaToolbar } from '../../../application';
|
||||
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
||||
import { useCollection_deprecated } from '../../../collection-manager';
|
||||
import { ButtonEditor, SecondConFirm } from '../../../schema-component/antd/action/Action.Designer';
|
||||
import {
|
||||
ButtonEditor,
|
||||
SecondConFirm,
|
||||
RefreshDataBlockRequest,
|
||||
} from '../../../schema-component/antd/action/Action.Designer';
|
||||
import { SchemaSettingsLinkageRules } from '../../../schema-settings';
|
||||
|
||||
export const deleteActionSettings = new SchemaSettings({
|
||||
@ -31,6 +35,15 @@ export const deleteActionSettings = new SchemaSettings({
|
||||
name: 'secondConFirm',
|
||||
Component: SecondConFirm,
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'delete',
|
||||
type: 'remove',
|
||||
|
@ -16,6 +16,7 @@ export const DisassociateActionInitializer = (props) => {
|
||||
title: "{{t('Disassociate record')}}",
|
||||
content: "{{t('Are you sure you want to disassociate it?')}}",
|
||||
},
|
||||
refreshDataBlockRequest: true,
|
||||
},
|
||||
'x-action-settings': {
|
||||
triggerWorkflows: [],
|
||||
|
@ -1,7 +1,11 @@
|
||||
import { useSchemaToolbar } from '../../../application';
|
||||
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
||||
import { useCollection_deprecated } from '../../../collection-manager';
|
||||
import { ButtonEditor, SecondConFirm } from '../../../schema-component/antd/action/Action.Designer';
|
||||
import {
|
||||
ButtonEditor,
|
||||
SecondConFirm,
|
||||
RefreshDataBlockRequest,
|
||||
} from '../../../schema-component/antd/action/Action.Designer';
|
||||
import { SchemaSettingsLinkageRules } from '../../../schema-settings';
|
||||
|
||||
export const disassociateActionSettings = new SchemaSettings({
|
||||
@ -27,6 +31,15 @@ export const disassociateActionSettings = new SchemaSettings({
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'secondConFirm',
|
||||
Component: SecondConFirm,
|
||||
|
@ -10,6 +10,7 @@ import {
|
||||
SecondConFirm,
|
||||
SkipValidation,
|
||||
WorkflowConfig,
|
||||
RefreshDataBlockRequest,
|
||||
} from '../../../schema-component/antd/action/Action.Designer';
|
||||
|
||||
export const customizeSaveRecordActionSettings = new SchemaSettings({
|
||||
@ -47,6 +48,15 @@ export const customizeSaveRecordActionSettings = new SchemaSettings({
|
||||
name: 'bindWorkflow',
|
||||
Component: WorkflowConfig,
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'delete',
|
||||
sort: 100,
|
||||
|
@ -10,6 +10,7 @@ import {
|
||||
RemoveButton,
|
||||
SecondConFirm,
|
||||
WorkflowConfig,
|
||||
RefreshDataBlockRequest,
|
||||
} from '../../../schema-component/antd/action/Action.Designer';
|
||||
import { SchemaSettingsLinkageRules } from '../../../schema-settings';
|
||||
|
||||
@ -56,6 +57,15 @@ export const customizeUpdateRecordActionSettings = new SchemaSettings({
|
||||
return isValid(fieldSchema?.['x-action-settings']?.triggerWorkflows);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'delete',
|
||||
sort: 100,
|
||||
|
@ -12,6 +12,7 @@ export const PopupActionInitializer = (props) => {
|
||||
'x-component': props?.['x-component'] || 'Action.Link',
|
||||
'x-component-props': {
|
||||
openMode: 'drawer',
|
||||
refreshDataBlockRequest: true,
|
||||
},
|
||||
properties: {
|
||||
drawer: {
|
||||
|
@ -1,7 +1,11 @@
|
||||
import { useSchemaToolbar } from '../../../application';
|
||||
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
||||
import { useCollection_deprecated } from '../../../collection-manager';
|
||||
import { ButtonEditor, RemoveButton } from '../../../schema-component/antd/action/Action.Designer';
|
||||
import {
|
||||
ButtonEditor,
|
||||
RemoveButton,
|
||||
RefreshDataBlockRequest,
|
||||
} from '../../../schema-component/antd/action/Action.Designer';
|
||||
import { SchemaSettingOpenModeSchemaItems } from '../../../schema-items';
|
||||
import { SchemaSettingsLinkageRules } from '../../../schema-settings';
|
||||
|
||||
|
@ -703,6 +703,19 @@ export const actionSettingsItems: SchemaSettingOptions['items'] = [
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return isValid(fieldSchema?.['x-action-settings']?.triggerWorkflows);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'remove',
|
||||
sort: 100,
|
||||
@ -792,5 +805,30 @@ export const ActionDesigner = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export function RefreshDataBlockRequest(props) {
|
||||
const { dn } = useDesignable();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { t } = useTranslation();
|
||||
const { refreshDataBlockRequest } = fieldSchema?.['x-component-props'] || {};
|
||||
return (
|
||||
<SchemaSettingsSwitchItem
|
||||
title={t('Refresh data on action')}
|
||||
//兼容历史数据
|
||||
checked={refreshDataBlockRequest !== false}
|
||||
onChange={(value) => {
|
||||
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||
fieldSchema['x-component-props'].refreshDataBlockRequest = value;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-component-props': {
|
||||
...fieldSchema['x-component-props'],
|
||||
},
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
ActionDesigner.ButtonEditor = ButtonEditor;
|
||||
ActionDesigner.RemoveButton = RemoveButton;
|
||||
|
@ -27,6 +27,7 @@ import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction';
|
||||
import { ComposedAction } from './types';
|
||||
import { linkageAction } from './utils';
|
||||
import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps';
|
||||
import { useDataBlockRequest } from '../../../data-source';
|
||||
|
||||
export const Action: ComposedAction = withDynamicSchemaProps(
|
||||
observer((props: any) => {
|
||||
@ -65,6 +66,7 @@ export const Action: ComposedAction = withDynamicSchemaProps(
|
||||
const designerProps = fieldSchema['x-designer-props'];
|
||||
const openMode = fieldSchema?.['x-component-props']?.['openMode'];
|
||||
const openSize = fieldSchema?.['x-component-props']?.['openSize'];
|
||||
const refreshDataBlockRequest = fieldSchema?.['x-component-props']?.['refreshDataBlockRequest'];
|
||||
|
||||
const disabled = form.disabled || field.disabled || field.data?.disabled || propsDisabled;
|
||||
const linkageRules = useMemo(() => fieldSchema?.['x-linkage-rules'] || [], [fieldSchema?.['x-linkage-rules']]);
|
||||
@ -75,7 +77,7 @@ export const Action: ComposedAction = withDynamicSchemaProps(
|
||||
const localVariables = useLocalVariables({ currentForm: { values: record } as any });
|
||||
const { getAriaLabel } = useGetAriaLabelOfAction(title);
|
||||
const [btnHover, setBtnHover] = useState(popover);
|
||||
|
||||
const service = useDataBlockRequest();
|
||||
useEffect(() => {
|
||||
if (popover) {
|
||||
setBtnHover(true);
|
||||
@ -117,9 +119,16 @@ export const Action: ComposedAction = withDynamicSchemaProps(
|
||||
|
||||
if (!disabled && aclCtx) {
|
||||
const onOk = () => {
|
||||
onClick?.(e);
|
||||
if (onClick) {
|
||||
onClick(e, () => {
|
||||
if (refreshDataBlockRequest !== false) {
|
||||
service?.refresh?.();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setVisible(true);
|
||||
run();
|
||||
}
|
||||
};
|
||||
if (confirm?.content) {
|
||||
modal.confirm({
|
||||
|
@ -1,15 +1,38 @@
|
||||
import { Schema } from '@formily/react';
|
||||
import { DrawerProps, ModalProps } from 'antd';
|
||||
import React, { createContext } from 'react';
|
||||
import React, { createContext, useEffect, useRef, useState } from 'react';
|
||||
import { useActionContext } from './hooks';
|
||||
import { useDataBlockRequest } from '../../../data-source';
|
||||
|
||||
export const ActionContext = createContext<ActionContextProps>({});
|
||||
ActionContext.displayName = 'ActionContext';
|
||||
|
||||
export const ActionContextProvider: React.FC<ActionContextProps & { value?: ActionContextProps }> = (props) => {
|
||||
const [submitted, setSubmitted] = useState(false); //是否有提交记录
|
||||
const contextProps = useActionContext();
|
||||
const { visible } = { ...props, ...props.value } || {};
|
||||
const isFirstRender = useRef(true); // 使用ref跟踪是否为首次渲染
|
||||
const service = useDataBlockRequest();
|
||||
const { setSubmitted: setParentSubmitted } = { ...props, ...props.value, ...contextProps };
|
||||
|
||||
useEffect(() => {
|
||||
if (visible !== undefined) {
|
||||
if (isFirstRender.current) {
|
||||
isFirstRender.current = false;
|
||||
} else {
|
||||
if (visible === false && submitted) {
|
||||
service.refresh();
|
||||
setParentSubmitted?.(true); //传递给上一层
|
||||
}
|
||||
}
|
||||
}
|
||||
return () => {
|
||||
setSubmitted(false);
|
||||
};
|
||||
}, [visible]);
|
||||
|
||||
return (
|
||||
<ActionContext.Provider value={{ ...contextProps, ...props, ...props?.value }}>
|
||||
<ActionContext.Provider value={{ ...contextProps, ...props, ...props?.value, submitted, setSubmitted }}>
|
||||
{props.children}
|
||||
</ActionContext.Provider>
|
||||
);
|
||||
@ -29,4 +52,6 @@ export interface ActionContextProps {
|
||||
fieldSchema?: Schema;
|
||||
drawerProps?: DrawerProps;
|
||||
modalProps?: ModalProps;
|
||||
submitted?: boolean;
|
||||
setSubmitted?: (v: boolean) => void;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ const InternalCreateRecordAction = (props: any, ref) => {
|
||||
return (
|
||||
//@ts-ignore
|
||||
<div className={actionDesignerCss} ref={buttonRef as React.Ref<HTMLButtonElement>}>
|
||||
<ActionContextProvider value={{ ...ctx, visible, setVisible }}>
|
||||
<ActionContextProvider value={{ ...ctx, fieldSchema, visible, setVisible }}>
|
||||
<CreateAction
|
||||
{...props}
|
||||
onClick={(collectionData) => {
|
||||
|
@ -1,39 +1,40 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { uid } from '@formily/shared';
|
||||
import { useBulkDestroyActionProps, useDestroyActionProps, useUpdateActionProps } from '../../block-provider/hooks';
|
||||
import { useSchemaTemplateManager } from '../SchemaTemplateManagerProvider';
|
||||
import { uiSchemaTemplatesCollection } from '../collections/uiSchemaTemplates';
|
||||
import { CollectionTitle } from './CollectionTitle';
|
||||
import { useBlockRequestContext } from '../../block-provider';
|
||||
|
||||
const useUpdateSchemaTemplateActionProps = () => {
|
||||
const props = useUpdateActionProps();
|
||||
const { refresh } = useSchemaTemplateManager();
|
||||
const { __parent } = useBlockRequestContext();
|
||||
return {
|
||||
async onClick() {
|
||||
await props.onClick();
|
||||
refresh();
|
||||
__parent?.service?.refresh?.();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const useBulkDestroyTemplateProps = () => {
|
||||
const props = useBulkDestroyActionProps();
|
||||
const { refresh } = useSchemaTemplateManager();
|
||||
const { service } = useBlockRequestContext();
|
||||
|
||||
return {
|
||||
async onClick() {
|
||||
await props.onClick();
|
||||
refresh();
|
||||
service?.refresh?.();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const useDestroyTemplateProps = () => {
|
||||
const props = useDestroyActionProps();
|
||||
const { refresh } = useSchemaTemplateManager();
|
||||
const { service } = useBlockRequestContext();
|
||||
return {
|
||||
async onClick() {
|
||||
await props.onClick();
|
||||
refresh();
|
||||
service?.refresh?.();
|
||||
},
|
||||
};
|
||||
};
|
||||
@ -122,6 +123,7 @@ export const uiSchemaTemplatesSchema: ISchema = {
|
||||
'x-component-props': {
|
||||
openMode: 'drawer',
|
||||
icon: 'EditOutlined',
|
||||
refreshDataBlockRequest: false,
|
||||
},
|
||||
properties: {
|
||||
drawer: {
|
||||
|
@ -4,10 +4,8 @@ import {
|
||||
SchemaInitializerOpenModeSchemaItems,
|
||||
SchemaSettings,
|
||||
SchemaSettingsDivider,
|
||||
SchemaSettingsItemGroup,
|
||||
SchemaSettingsRemove,
|
||||
SchemaSettingsSelectItem,
|
||||
useCompile,
|
||||
useDesignable,
|
||||
useSchemaToolbar,
|
||||
} from '@nocobase/client';
|
||||
|
@ -86,7 +86,7 @@ export const useCustomizeBulkEditActionProps = () => {
|
||||
const { rowKey } = tableBlockContext;
|
||||
const selectedRecordKeys =
|
||||
tableBlockContext.field?.data?.selectedRowKeys ?? expressionScope?.selectedRecordKeys ?? {};
|
||||
const { setVisible, fieldSchema: actionSchema } = actionContext;
|
||||
const { setVisible, fieldSchema: actionSchema, setSubmitted } = actionContext;
|
||||
return {
|
||||
async onClick() {
|
||||
const { onSuccess, skipValidator, updateMode } = actionSchema?.['x-action-settings'] ?? {};
|
||||
@ -130,8 +130,9 @@ export const useCustomizeBulkEditActionProps = () => {
|
||||
if (!(resource instanceof TableFieldResource)) {
|
||||
__parent?.__parent?.service?.refresh?.();
|
||||
}
|
||||
__parent?.service?.refresh?.();
|
||||
// __parent?.service?.refresh?.();
|
||||
setVisible?.(false);
|
||||
setSubmitted(true);
|
||||
if (!onSuccess?.successMessage) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
AssignedFieldValues,
|
||||
useDesignable,
|
||||
useSchemaToolbar,
|
||||
RefreshDataBlockRequest,
|
||||
} from '@nocobase/client';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import React from 'react';
|
||||
@ -139,6 +140,15 @@ const schemaSettingsItems: SchemaSettingsItemType[] = [
|
||||
return isValid(fieldSchema?.['x-action-settings']?.onSuccess);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'remove',
|
||||
sort: 100,
|
||||
|
@ -36,7 +36,7 @@ export const useCustomizeBulkUpdateActionProps = () => {
|
||||
const localVariables = useLocalVariables();
|
||||
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e, callBack) {
|
||||
const {
|
||||
assignedValues: originalAssignedValues = {},
|
||||
onSuccess,
|
||||
@ -98,7 +98,10 @@ export const useCustomizeBulkUpdateActionProps = () => {
|
||||
} finally {
|
||||
actionField.data.loading = false;
|
||||
}
|
||||
service?.refresh?.();
|
||||
if (callBack) {
|
||||
callBack?.();
|
||||
}
|
||||
// service?.refresh?.();
|
||||
if (!(resource instanceof TableFieldResource)) {
|
||||
__parent?.service?.refresh?.();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export const useCustomizeRequestActionProps = () => {
|
||||
const { setVisible } = useActionContext();
|
||||
const { modal, message } = App.useApp();
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e?, callBack?) {
|
||||
const { skipValidator, onSuccess } = actionSchema?.['x-action-settings'] ?? {};
|
||||
const xAction = actionSchema?.['x-action'];
|
||||
if (skipValidator !== true && xAction === 'customize:form:request') {
|
||||
@ -56,7 +56,10 @@ export const useCustomizeRequestActionProps = () => {
|
||||
if (!(resource instanceof TableFieldResource)) {
|
||||
__parent?.service?.refresh?.();
|
||||
}
|
||||
service?.refresh?.();
|
||||
// service?.refresh?.();
|
||||
if (callBack) {
|
||||
callBack?.();
|
||||
}
|
||||
if (xAction === 'customize:form:request') {
|
||||
setVisible?.(false);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
SecondConFirm,
|
||||
useCollection,
|
||||
useSchemaToolbar,
|
||||
RefreshDataBlockRequest,
|
||||
} from '@nocobase/client';
|
||||
import { CustomRequestACL, CustomRequestSettingsItem } from './components/CustomRequestActionDesigner';
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
@ -52,6 +53,15 @@ export const customizeCustomRequestActionSettings = new SchemaSettings({
|
||||
name: 'accessControl',
|
||||
Component: CustomRequestACL,
|
||||
},
|
||||
{
|
||||
name: 'refreshDataBlockRequest',
|
||||
Component: RefreshDataBlockRequest,
|
||||
useComponentProps() {
|
||||
return {
|
||||
isPopupAction: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'delete',
|
||||
sort: 100,
|
||||
|
@ -92,7 +92,7 @@ export const useImportStartAction = () => {
|
||||
const { t } = useTranslation(NAMESPACE);
|
||||
const { schema: importSchema } = useImportSchema(actionSchema);
|
||||
const form = useForm();
|
||||
const { setVisible } = useActionContext();
|
||||
const { setVisible, fieldSchema } = useActionContext();
|
||||
const { setImportModalVisible, setImportStatus, setImportResult } = useImportContext();
|
||||
return {
|
||||
async run() {
|
||||
|
@ -82,13 +82,13 @@ export function useRecordTriggerWorkflowsActionProps() {
|
||||
const actionField = useField();
|
||||
const actionSchema = useFieldSchema();
|
||||
const { field, __parent } = useBlockRequestContext();
|
||||
const { setVisible } = useActionContext();
|
||||
const { setVisible, setSubmitted } = useActionContext();
|
||||
const { modal } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
const { onSuccess, triggerWorkflows } = actionSchema?.['x-action-settings'] ?? {};
|
||||
|
||||
return {
|
||||
async onClick() {
|
||||
async onClick(e?, callBack?) {
|
||||
actionField.data = field.data || {};
|
||||
actionField.data.loading = true;
|
||||
|
||||
@ -100,8 +100,12 @@ export function useRecordTriggerWorkflowsActionProps() {
|
||||
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
|
||||
: undefined,
|
||||
});
|
||||
__parent?.service?.refresh?.();
|
||||
// __parent?.service?.refresh?.();
|
||||
if (callBack) {
|
||||
callBack();
|
||||
}
|
||||
setVisible?.(false);
|
||||
setSubmitted?.(true);
|
||||
if (!onSuccess?.successMessage) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user