refactor: collection template support forbidDeletion setting (#3139)
This commit is contained in:
parent
cb200de34e
commit
d573e6ff17
@ -64,7 +64,7 @@ const CurrentFields = (props) => {
|
|||||||
const { [targetKey]: filterByTk, titleField, template } = useRecord();
|
const { [targetKey]: filterByTk, titleField, template } = useRecord();
|
||||||
const [loadingRecord, setLoadingRecord] = React.useState<any>(null);
|
const [loadingRecord, setLoadingRecord] = React.useState<any>(null);
|
||||||
const { refreshCM, isTitleField, getTemplate } = useCollectionManager();
|
const { refreshCM, isTitleField, getTemplate } = useCollectionManager();
|
||||||
|
const targetTemplate = getTemplate(template);
|
||||||
const columns: TableColumnProps<any>[] = [
|
const columns: TableColumnProps<any>[] = [
|
||||||
{
|
{
|
||||||
dataIndex: ['uiSchema', 'rawTitle'],
|
dataIndex: ['uiSchema', 'rawTitle'],
|
||||||
@ -130,7 +130,7 @@ const CurrentFields = (props) => {
|
|||||||
content: t('Are you sure you want to delete it?'),
|
content: t('Are you sure you want to delete it?'),
|
||||||
},
|
},
|
||||||
useAction: useDestroyActionAndRefreshCM,
|
useAction: useDestroyActionAndRefreshCM,
|
||||||
disabled: isDeleteButtonDisabled(record),
|
disabled: isDeleteButtonDisabled(record) || targetTemplate?.forbidDeletion,
|
||||||
title: t('Delete'),
|
title: t('Delete'),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -405,6 +405,7 @@ export const CollectionFields = () => {
|
|||||||
useAction: useBulkDestroyActionAndRefreshCM,
|
useAction: useBulkDestroyActionAndRefreshCM,
|
||||||
title: t('Delete'),
|
title: t('Delete'),
|
||||||
icon: 'DeleteOutlined',
|
icon: 'DeleteOutlined',
|
||||||
|
disabled: targetTemplate?.forbidDeletion,
|
||||||
confirm: {
|
confirm: {
|
||||||
title: t('Delete record'),
|
title: t('Delete record'),
|
||||||
content: t('Are you sure you want to delete it?'),
|
content: t('Are you sure you want to delete it?'),
|
||||||
|
@ -20,6 +20,8 @@ export interface ICollectionTemplate {
|
|||||||
description?: string;
|
description?: string;
|
||||||
/**配置字段中的操作按钮 */
|
/**配置字段中的操作按钮 */
|
||||||
configureActions?: Record<string, ISchema>;
|
configureActions?: Record<string, ISchema>;
|
||||||
|
//是否禁止删除字段
|
||||||
|
forbidDeletion?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AvailableFieldInterfacesInclude {
|
interface AvailableFieldInterfacesInclude {
|
||||||
|
Loading…
Reference in New Issue
Block a user