Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular - Extensible table logic errors for action list #19846

Merged
merged 8 commits into from
May 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*ngTemplateOutlet="actionsTemplate || gridActions; context: { $implicit: row, index: i }"
></ng-container>
<ng-template #gridActions>
@if (hasAvailableActions(row)) {
@if (isVisibleActions(row)) {
<abp-grid-actions [index]="i" [record]="row" text="AbpUi::Actions"></abp-grid-actions>
}
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,25 @@ export class ExtensibleTableComponent<R = any> implements OnChanges {
});
}

hasAvailableActions(rowData): boolean {
let isActionAvailable = true;
this.actionList.toArray().map(action => {
isVisibleActions(rowData: any): boolean {
const actions = this.actionList.toArray();
const visibleActions = actions.filter(action => {
const { visible, permission } = action;
if (rowData && action) {
const visibilityCheck = visible({
record: rowData,
getInjected: this.getInjected,
});
const permissionCheck = this.permissionService.getGrantedPolicy(permission);

isActionAvailable = visibilityCheck && permissionCheck;

let isVisible = true;
let hasPermission = true;

if (visible) {
isVisible = visible({ record: rowData, getInjected: this.getInjected });
}

if (permission) {
hasPermission = this.permissionService.getGrantedPolicy(permission);
}

return isVisible && hasPermission;
});
return isActionAvailable;

return visibleActions.length > 0;
}
}
Loading