From d573e6ff171d836aacc6b0411172149440aa6255 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Tue, 5 Dec 2023 15:58:36 +0800 Subject: [PATCH] refactor: collection template support forbidDeletion setting (#3139) --- .../collection-manager/Configuration/CollectionFields.tsx | 5 +++-- .../core/client/src/collection-manager/templates/types.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx b/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx index 350aed573..09d709132 100644 --- a/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx +++ b/packages/core/client/src/collection-manager/Configuration/CollectionFields.tsx @@ -64,7 +64,7 @@ const CurrentFields = (props) => { const { [targetKey]: filterByTk, titleField, template } = useRecord(); const [loadingRecord, setLoadingRecord] = React.useState(null); const { refreshCM, isTitleField, getTemplate } = useCollectionManager(); - + const targetTemplate = getTemplate(template); const columns: TableColumnProps[] = [ { dataIndex: ['uiSchema', 'rawTitle'], @@ -130,7 +130,7 @@ const CurrentFields = (props) => { content: t('Are you sure you want to delete it?'), }, useAction: useDestroyActionAndRefreshCM, - disabled: isDeleteButtonDisabled(record), + disabled: isDeleteButtonDisabled(record) || targetTemplate?.forbidDeletion, title: t('Delete'), }; @@ -405,6 +405,7 @@ export const CollectionFields = () => { useAction: useBulkDestroyActionAndRefreshCM, title: t('Delete'), icon: 'DeleteOutlined', + disabled: targetTemplate?.forbidDeletion, confirm: { title: t('Delete record'), content: t('Are you sure you want to delete it?'), diff --git a/packages/core/client/src/collection-manager/templates/types.ts b/packages/core/client/src/collection-manager/templates/types.ts index e197b2b55..c57c8e0e9 100644 --- a/packages/core/client/src/collection-manager/templates/types.ts +++ b/packages/core/client/src/collection-manager/templates/types.ts @@ -20,6 +20,8 @@ export interface ICollectionTemplate { description?: string; /**配置字段中的操作按钮 */ configureActions?: Record; + //是否禁止删除字段 + forbidDeletion?: boolean; } interface AvailableFieldInterfacesInclude {