show actions conditinally on description-template-listing
This commit is contained in:
parent
6e12d13a3b
commit
a2a3f5000d
|
@ -86,29 +86,29 @@
|
|||
</ng-template>
|
||||
|
||||
<ng-template #actions let-row="row" let-item>
|
||||
<div class="row" (click)="$event.stopPropagation()">
|
||||
<div *ngIf="showActions(row)" class="row" (click)="$event.stopPropagation()">
|
||||
<div class="col-auto">
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||
<mat-icon>more_horiz</mat-icon>
|
||||
</button>
|
||||
<mat-menu #actionsMenu="matMenu">
|
||||
<button *ngIf="row.status !== descriptionTemplateStatuses.Finalized && hasPermission(permissionEnum.EditDescriptionTemplate, row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/', row.id])">
|
||||
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/', row.id])">
|
||||
<mat-icon>edit</mat-icon>{{'DESCRIPTION-TEMPLATE-LISTING.ACTIONS.EDIT' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && hasExplicitPermission(permissionEnum.EditDescriptionTemplate)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/new-version/', row.id])">
|
||||
<button *ngIf="canAddNewVersion(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/new-version/', row.id])">
|
||||
<mat-icon>queue</mat-icon>{{'DESCRIPTION-TEMPLATE-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && hasPermission(permissionEnum.CloneDescriptionTemplate, row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/clone/', row.id])">
|
||||
<button *ngIf="canClone(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/clone/', row.id])">
|
||||
<mat-icon>content_copy</mat-icon>{{'DESCRIPTION-TEMPLATE-LISTING.ACTIONS.CLONE' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && hasExplicitPermission(permissionEnum.EditDescriptionTemplate)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/versions/', row.groupId])">
|
||||
<button *ngIf="canViewVersions(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-templates/versions/', row.groupId])">
|
||||
<mat-icon>library_books</mat-icon>
|
||||
{{'DESCRIPTION-TEMPLATE-LISTING.ACTIONS.VIEW-VERSIONS' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && hasPermission(permissionEnum.ExportDescriptionTemplate, row)" mat-menu-item (click)="export($event, row.id)">
|
||||
<button *ngIf="canDownloadXml(row)" mat-menu-item (click)="export($event, row.id)">
|
||||
<mat-icon>download</mat-icon>{{'DESCRIPTION-TEMPLATE-LISTING.ACTIONS.DOWNLOAD-XML' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && hasPermission(permissionEnum.DeleteDescriptionTemplate, row)" mat-menu-item (click)="delete(row.id)">
|
||||
<button *ngIf="canDelete(row)" mat-menu-item (click)="delete(row.id)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
{{'DESCRIPTION-TEMPLATE-LISTING.ACTIONS.DELETE' | translate}}
|
||||
</button>
|
||||
|
|
|
@ -192,6 +192,36 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
|
|||
this.onColumnsChangedInternal(event.properties.map(x => x.toString()));
|
||||
}
|
||||
|
||||
public showActions(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return this.canEdit(descriptionTemplate) || this.canAddNewVersion(descriptionTemplate) ||
|
||||
this.canClone(descriptionTemplate) || this.canViewVersions(descriptionTemplate) ||
|
||||
this.canDownloadXml(descriptionTemplate) || this.canDelete(descriptionTemplate);
|
||||
}
|
||||
|
||||
public canEdit(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return descriptionTemplate.status !== DescriptionTemplateStatus.Finalized && this.hasPermission(AppPermission.EditDescriptionTemplate, descriptionTemplate);
|
||||
}
|
||||
|
||||
public canAddNewVersion(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return descriptionTemplate.belongsToCurrentTenant != false && this.hasExplicitPermission(AppPermission.EditDescriptionTemplate);
|
||||
}
|
||||
|
||||
public canClone(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.CloneDescriptionTemplate, descriptionTemplate);
|
||||
}
|
||||
|
||||
public canViewVersions(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return descriptionTemplate.belongsToCurrentTenant != false && this.hasExplicitPermission(AppPermission.EditDescriptionTemplate);
|
||||
}
|
||||
|
||||
public canDownloadXml(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.ExportDescriptionTemplate, descriptionTemplate);
|
||||
}
|
||||
|
||||
public canDelete(descriptionTemplate: DescriptionTemplate): boolean {
|
||||
return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.DeleteDescriptionTemplate, descriptionTemplate);
|
||||
}
|
||||
|
||||
private onColumnsChangedInternal(columns: string[]) {
|
||||
// Here are defined the projection fields that always requested from the api.
|
||||
const fields = new Set(this.lookupFields);
|
||||
|
|
Loading…
Reference in New Issue