From 0214bb915ef5c48d66c4d351d8dbedf67dcd40c5 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Tue, 7 May 2024 09:44:55 +0800 Subject: [PATCH] fix: bulk delete collection field should not close modal (#4263) --- .../Configuration/DeleteCollectionAction.tsx | 14 ++++++++++---- .../Configuration/CollectionFields.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/DeleteCollectionAction.tsx b/packages/core/client/src/collection-manager/Configuration/DeleteCollectionAction.tsx index ad6503fec4..f5f3b7af7e 100644 --- a/packages/core/client/src/collection-manager/Configuration/DeleteCollectionAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/DeleteCollectionAction.tsx @@ -39,12 +39,18 @@ export const useDestroyActionAndRefreshCM = () => { }, }; }; -export const useBulkDestroyActionAndRefreshCM = () => { + +/** + * 是否关闭弹窗 + * @param flag + * @returns + */ +export const useBulkDestroyActionAndRefreshCM = (flag?) => { const { run } = useBulkDestroyAction(); const { refreshCM } = useCollectionManager_deprecated(); return { async run() { - await run(); + await run(flag); await refreshCM(); }, }; @@ -71,7 +77,7 @@ export const useBulkDestroyAction = () => { const form = useForm(); const { cascade } = form?.values || {}; return { - async run() { + async run(flag?) { if (!state?.selectedRowKeys?.length) { return message.error(t('Please select the records you want to delete')); } @@ -80,7 +86,7 @@ export const useBulkDestroyAction = () => { cascade, }); form.reset(); - ctx?.setVisible?.(false); + !flag && ctx?.setVisible?.(false); setState?.({ selectedRowKeys: [] }); refresh(); }, diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/CollectionFields.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/CollectionFields.tsx index 5568301b9d..0c012dbda2 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/CollectionFields.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/CollectionFields.tsx @@ -413,7 +413,7 @@ const CollectionFieldsInternal = () => { const deleteProps = useMemo( () => ({ - useAction: useBulkDestroyActionAndRefreshCM, + useAction: () => useBulkDestroyActionAndRefreshCM(true), title: t('Delete'), icon: 'DeleteOutlined', disabled: targetTemplate?.forbidDeletion,