fix: field permission all fields should be displayed (#3799)

This commit is contained in:
katherinehhh 2024-03-23 18:41:57 +08:00 committed by GitHub
parent 35a6514993
commit fbed0201aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,9 +51,7 @@ export const RolesResourcesActions = connect((props) => {
return action?.fields?.includes(fieldName); return action?.fields?.includes(fieldName);
}; };
const availableActionsWithFields = availableActions.filter((action) => action.allowConfigureFields); const availableActionsWithFields = availableActions.filter((action) => action.allowConfigureFields);
const fieldPermissions = collectionFields const fieldPermissions = collectionFields?.map((field) => {
?.filter((field) => field.interface)
?.map((field) => {
const permission = { ...field }; const permission = { ...field };
for (const action of availableActionsWithFields) { for (const action of availableActionsWithFields) {
permission[action.name] = inAction(action.name, field.name); permission[action.name] = inAction(action.name, field.name);
@ -83,8 +81,7 @@ export const RolesResourcesActions = connect((props) => {
}; };
const allChecked = {}; const allChecked = {};
for (const action of availableActionsWithFields) { for (const action of availableActionsWithFields) {
allChecked[action.name] = allChecked[action.name] = collectionFields?.length === actionMap?.[action.name]?.fields?.length;
collectionFields?.filter((field) => field.interface)?.length === actionMap?.[action.name]?.fields?.length;
} }
return ( return (
<div> <div>
@ -163,7 +160,7 @@ export const RolesResourcesActions = connect((props) => {
{ {
dataIndex: ['uiSchema', 'title'], dataIndex: ['uiSchema', 'title'],
title: t('Field display name'), title: t('Field display name'),
render: (value) => compile(value), render: (value, record) => compile(value) || record.name,
}, },
...availableActionsWithFields.map((action) => { ...availableActionsWithFields.map((action) => {
const checked = allChecked?.[action.name]; const checked = allChecked?.[action.name];
@ -185,7 +182,7 @@ export const RolesResourcesActions = connect((props) => {
actionMap[action.name] = item; actionMap[action.name] = item;
onChange(Object.values(actionMap)); onChange(Object.values(actionMap));
}} }}
/>{' '} />
{compile(action.displayName)} {compile(action.displayName)}
</> </>
), ),