refactor: collection template support forbidDeletion setting (#3139)

This commit is contained in:
katherinehhh 2023-12-05 15:58:36 +08:00 committed by GitHub
parent cb200de34e
commit d573e6ff17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -64,7 +64,7 @@ const CurrentFields = (props) => {
const { [targetKey]: filterByTk, titleField, template } = useRecord();
const [loadingRecord, setLoadingRecord] = React.useState<any>(null);
const { refreshCM, isTitleField, getTemplate } = useCollectionManager();
const targetTemplate = getTemplate(template);
const columns: TableColumnProps<any>[] = [
{
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?'),

View File

@ -20,6 +20,8 @@ export interface ICollectionTemplate {
description?: string;
/**配置字段中的操作按钮 */
configureActions?: Record<string, ISchema>;
//是否禁止删除字段
forbidDeletion?: boolean;
}
interface AvailableFieldInterfacesInclude {