|
|
|
@ -211,13 +211,22 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
|
const visibleActions = actions.filter(action => { |
|
|
|
const { visible, permission } = action; |
|
|
|
|
|
|
|
if (permission && visible) { |
|
|
|
const visibilityCheck = visible({ record: rowData, getInjected: this.getInjected }); |
|
|
|
const permissionCheck = this.permissionService.getGrantedPolicy(permission); |
|
|
|
return visibilityCheck && permissionCheck; |
|
|
|
// Case 1: assuming that the action has neither permission nor visible properties, so no need to make an extra check
|
|
|
|
let isVisible = true; |
|
|
|
let hasPermission = true; |
|
|
|
|
|
|
|
// Case 2: action has visible condition
|
|
|
|
if (visible) { |
|
|
|
isVisible = visible({ record: rowData, getInjected: this.getInjected }); |
|
|
|
} |
|
|
|
|
|
|
|
// Case 3: action has permission condition
|
|
|
|
if (permission) { |
|
|
|
hasPermission = this.permissionService.getGrantedPolicy(permission); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
// Return true if the action is both visible and has permission, otherwise return false
|
|
|
|
return isVisible && hasPermission; |
|
|
|
}); |
|
|
|
|
|
|
|
return visibleActions.length > 0; |
|
|
|
|