plan blueprint listing > add checks for row actions
This commit is contained in:
parent
1bf3fae0b8
commit
481e712edd
|
@ -85,10 +85,10 @@
|
|||
<mat-icon>more_horiz</mat-icon>
|
||||
</button>
|
||||
<mat-menu #actionsMenu="matMenu">
|
||||
<button *ngIf="(row.status != null && row.status === planBlueprintStatuses.Draft && row.isActive == isActive.Active)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-blueprints/', row.id])">
|
||||
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-blueprints/', row.id])">
|
||||
<mat-icon>edit</mat-icon>{{'PLAN-BLUEPRINT-LISTING.ACTIONS.EDIT' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && (row.status === planBlueprintStatuses.Finalized || row.status == null)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-blueprints/new-version/', row.id])">
|
||||
<button *ngIf="canCreateNewVersion(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-blueprints/new-version/', row.id])">
|
||||
<mat-icon>queue</mat-icon>{{'PLAN-BLUEPRINT-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-blueprints/clone/', row.id])">
|
||||
|
@ -98,10 +98,10 @@
|
|||
<mat-icon>library_books</mat-icon>
|
||||
{{'PLAN-BLUEPRINT-LISTING.ACTIONS.VIEW-VERSIONS' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="export($event, row.id)">
|
||||
<button mat-menu-item (click)="export($event, row.id)" *ngIf="canDownloadXML(row.id)">
|
||||
<mat-icon>download</mat-icon>{{'PLAN-BLUEPRINT-LISTING.ACTIONS.DOWNLOAD-XML' | translate}}
|
||||
</button>
|
||||
<button *ngIf="row.belongsToCurrentTenant != false && row.isActive == isActive.Active" mat-menu-item (click)="delete(row.id)">
|
||||
<button *ngIf="canDelete(row)" mat-menu-item (click)="delete(row.id)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
{{'PLAN-BLUEPRINT-LISTING.ACTIONS.DELETE' | translate}}
|
||||
</button>
|
||||
|
|
|
@ -30,6 +30,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||
import { nameof } from 'ts-simple-nameof';
|
||||
import { ImportPlanBlueprintDialogComponent } from './import-plan-blueprint/import-plan-blueprint.dialog.component';
|
||||
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -93,6 +94,26 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
|||
super.ngOnInit();
|
||||
}
|
||||
|
||||
protected isFinalized(blueprint: PlanBlueprint): boolean {
|
||||
return blueprint?.status == PlanBlueprintStatus.Finalized;
|
||||
}
|
||||
|
||||
protected canEdit(blueprint: PlanBlueprint): boolean {
|
||||
return this.authService.hasPermission(AppPermission.EditPlanBlueprint) && blueprint?.belongsToCurrentTenant && !this.isFinalized(blueprint) && (blueprint?.isActive === IsActive.Active);
|
||||
}
|
||||
|
||||
protected canCreateNewVersion(blueprint: PlanBlueprint): boolean {
|
||||
return blueprint?.belongsToCurrentTenant != false && (blueprint?.status === PlanBlueprintStatus.Finalized || blueprint?.status == null)
|
||||
}
|
||||
|
||||
protected canDelete(blueprint: PlanBlueprint): boolean {
|
||||
return this.authService.hasPermission(AppPermission.EditPlanBlueprint) && blueprint?.belongsToCurrentTenant && !this.isFinalized(blueprint) && (blueprint?.isActive === IsActive.Active);
|
||||
}
|
||||
|
||||
protected canDownloadXML(blueprint: PlanBlueprint): boolean {
|
||||
return this.authService.hasPermission(AppPermission.ExportPlanBlueprint) && this.isFinalized(blueprint);
|
||||
}
|
||||
|
||||
protected initializeLookup(): PlanBlueprintLookup {
|
||||
const lookup = new PlanBlueprintLookup();
|
||||
lookup.metadata = { countAll: true };
|
||||
|
@ -187,7 +208,7 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
|||
return this.planBlueprintService.query(this.lookup);
|
||||
}
|
||||
|
||||
public delete(id: Guid) {
|
||||
protected delete(id: Guid) {
|
||||
if (id) {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
|
@ -209,12 +230,12 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
|||
}
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
private onCallbackSuccess(): void {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
export(event: PointerEvent, id: Guid): void {
|
||||
protected export(event: PointerEvent, id: Guid): void {
|
||||
event?.stopPropagation();
|
||||
this.planBlueprintService.downloadXML(id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
|
@ -226,7 +247,7 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
|||
error => this.httpErrorHandlingService.handleBackedRequestError(error));
|
||||
}
|
||||
|
||||
import(): void {
|
||||
protected import(): void {
|
||||
const dialogRef = this.dialog.open(ImportPlanBlueprintDialogComponent, {
|
||||
restoreFocus: false,
|
||||
data: {
|
||||
|
|
Loading…
Reference in New Issue