listing actions

This commit is contained in:
CITE\spapacharalampous 2024-08-28 14:53:16 +03:00
parent b3b8b1d0c4
commit 313662587d
27 changed files with 139 additions and 46 deletions

View File

@ -80,10 +80,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/notification-templates/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/notification-templates/', row.id])">
<mat-icon>edit</mat-icon>{{'ANNOTATION-SERVICE.STATUS-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'ANNOTATION-SERVICE.STATUS-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -24,6 +24,7 @@ import { StatusService } from '@annotation-service/services/http/status.service'
import { AnnotationServiceEnumUtils } from '@annotation-service/core/formatting/enum-utils.service';
import { InternalStatusTypePipe } from '@annotation-service/core/formatting/pipes/internal-status-type.pipe';
import { IsActiveTypePipe } from '@annotation-service/core/formatting/pipes/is-active-type.pipe';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './status-listing.component.html',
@ -73,6 +74,14 @@ export class StatusListingComponent extends BaseListingComponent<Status, StatusL
super.ngOnInit();
}
protected canEdit(status: Status): boolean {
return status?.isActive === IsActive.Active;
}
protected canDelete(status: Status): boolean {
return status?.isActive === IsActive.Active;
}
protected initializeLookup(): StatusLookup {
const lookup = new StatusLookup();
lookup.metadata = { countAll: true };

View File

@ -54,10 +54,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button *ngIf="canEdit" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-statuses/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-statuses/', row.id])">
<mat-icon>edit</mat-icon>{{'COMMONS.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="canDelete" mat-menu-item (click)="delete(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="delete(row.id)">
<mat-icon>delete</mat-icon>
{{'COMMONS.ACTIONS.DELETE' | translate}}
</button>

View File

@ -67,6 +67,14 @@ export class DescriptionStatusListingComponent extends BaseListingComponent<Desc
this.analyticsService.trackPageView(AnalyticsService.DescriptionStatusListing);
}
protected canEdit(descriptionStatus: DescriptionStatus): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.EditDescriptionStatus) && descriptionStatus?.belongsToCurrentTenant && descriptionStatus?.isActive === IsActive.Active;
}
protected canDelete(descriptionStatus: DescriptionStatus): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.DeleteDescriptionStatus) && descriptionStatus?.belongsToCurrentTenant && descriptionStatus?.isActive === IsActive.Active;
}
private readonly lookupFields = DescriptionStatusEditorResolver.lookupFields();
protected initializeLookup(): DescriptionStatusLookup {
@ -179,12 +187,4 @@ export class DescriptionStatusListingComponent extends BaseListingComponent<Desc
isDeleted(row: DescriptionStatus): boolean {
return row?.isActive === IsActive.Inactive;
}
get canEdit(): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.EditDescriptionStatus);
}
get canDelete(): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.DeleteDescriptionStatus);
}
}

View File

@ -90,10 +90,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button *ngIf="!isFinalized(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-template-type/' + row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/description-template-type/' + row.id])">
<mat-icon>edit</mat-icon>{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -24,6 +24,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './description-template-type-listing.component.html',
@ -77,6 +78,14 @@ export class DescriptionTemplateTypeListingComponent extends BaseListingComponen
super.ngOnInit();
}
protected canEdit(descriptionType: DescriptionTemplateType): boolean {
return this.authService.hasPermission(AppPermission.EditDescriptionTemplateType) && descriptionType.belongsToCurrentTenant && !this.isFinalized(descriptionType) && descriptionType.isActive === IsActive.Active;
}
protected canDelete(descriptionType: DescriptionTemplateType): boolean {
return this.authService.hasPermission(AppPermission.DeleteDescriptionTemplateType) && descriptionType.belongsToCurrentTenant && descriptionType.isActive === IsActive.Active;
}
protected initializeLookup(): DescriptionTemplateTypeLookup {
const lookup = new DescriptionTemplateTypeLookup();
lookup.metadata = { countAll: true };

View File

@ -64,13 +64,13 @@
</ng-template>
<ng-template #actions let-row="row" let-item>
<div *ngIf="row.belongsToCurrentTenant != false" class="row" (click)="$event.stopPropagation()">
<div *ngIf="canDelete(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 mat-menu-item (click)="deleteType(row.id, row.target)">
<mat-menu #actionsMenu="matMenu">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id, row.target)">
<mat-icon>delete</mat-icon>
{{'LOCK-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -23,6 +23,7 @@ import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/serv
import { LockTargetTypePipe } from '@common/formatting/pipes/lock-target-type.pipe';
import { User } from '@app/core/model/user/user';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './lock-listing.component.html',
@ -73,6 +74,10 @@ export class LockListingComponent extends BaseListingComponent<Lock, LockLookup>
super.ngOnInit();
}
protected canDelete(lock: Lock): boolean {
return this.authService.hasPermission(AppPermission.DeleteLock) && lock?.belongsToCurrentTenant;
}
protected initializeLookup(): LockLookup {
const lookup = new LockLookup();
lookup.metadata = { countAll: true };

View File

@ -75,16 +75,16 @@
</ng-template>
<ng-template #actions let-row="row" let-item>
<div *ngIf="!isDeleted(row)" class="row" (click)="$event.stopPropagation()">
<div *ngIf="canEdit(row) || canDelete(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 mat-menu-item [routerLink]="routerUtils.generateUrl(['/languages/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/languages/', row.id])">
<mat-icon>edit</mat-icon>{{'LANGUAGE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'LANGUAGE-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -23,6 +23,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './language-listing.component.html',
@ -72,6 +73,14 @@ export class LanguageListingComponent extends BaseListingComponent<Language, Lan
super.ngOnInit();
}
protected canEdit(language: Language): boolean {
return this.authService.hasPermission(AppPermission.EditLanguage) && language?.belongsToCurrentTenant && language?.isActive === IsActive.Active;
}
protected canDelete(language: Language): boolean {
return this.authService.hasPermission(AppPermission.DeleteLanguage) && language?.belongsToCurrentTenant && language?.isActive === IsActive.Active;
}
protected initializeLookup(): LanguageLookup {
const lookup = new LanguageLookup();
lookup.metadata = { countAll: true };

View File

@ -112,7 +112,7 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
}
protected canDelete(blueprint: PlanBlueprint): boolean {
return this.authService.hasPermission(AppPermission.EditPlanBlueprint) && blueprint?.belongsToCurrentTenant && !this.isFinalized(blueprint) && (blueprint?.isActive === IsActive.Active);
return this.authService.hasPermission(AppPermission.EditPlanBlueprint) && blueprint?.belongsToCurrentTenant && (blueprint?.isActive === IsActive.Active);
}
protected canDownloadXML(blueprint: PlanBlueprint): boolean {

View File

@ -53,10 +53,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button *ngIf="canEdit" mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-statuses/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/plan-statuses/', row.id])">
<mat-icon>edit</mat-icon>{{'PLAN-STATUS-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="canDelete" mat-menu-item (click)="delete(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="delete(row.id)">
<mat-icon>delete</mat-icon>
{{'PLAN-STATUS-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -25,6 +25,7 @@ import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog
import { MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import { PlanStatusEnum } from '@app/core/common/enum/plan-status';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
selector: 'app-plan-status-listing',
@ -67,6 +68,14 @@ export class PlanStatusListingComponent extends BaseListingComponent<PlanStatus,
this.analyticsService.trackPageView(AnalyticsService.PlanStatusListing);
}
protected canEdit(planStatus: PlanStatus): boolean {
return this.authService.hasPermission(AppPermission.EditPlanStatus) && planStatus.belongsToCurrentTenant && planStatus?.isActive === IsActive.Active;
}
protected canDelete(planStatus: PlanStatus): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.DeletePlanStatus) && planStatus.belongsToCurrentTenant && planStatus?.isActive === IsActive.Active;
}
private readonly lookupFields = PlanStatusEditorResolver.lookupFields();
protected initializeLookup(): PlanStatusLookup {
@ -179,12 +188,4 @@ export class PlanStatusListingComponent extends BaseListingComponent<PlanStatus,
isDeleted(row: PlanStatus): boolean {
return row?.isActive === IsActive.Inactive;
}
get canEdit(): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.EditPlanStatus);
}
get canDelete(): boolean {
return this.authService.hasPermission(this.authService.permissionEnum.DeletePlanStatus);
}
}

View File

@ -83,10 +83,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/prefilling-sources/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/prefilling-sources/', row.id])">
<mat-icon>edit</mat-icon>{{'PREFILLING-SOURCE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'PREFILLING-SOURCE-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -23,6 +23,7 @@ import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './prefilling-source-listing.component.html',
@ -73,6 +74,15 @@ export class PrefillingSourceListingComponent extends BaseListingComponent<Prefi
super.ngOnInit();
}
protected canEdit(prefillingSource: PrefillingSource): boolean {
return this.authService.hasPermission(AppPermission.EditPrefillingSource) && prefillingSource?.belongsToCurrentTenant && prefillingSource?.isActive === IsActive.Active;
}
protected canDelete(prefillingSource: PrefillingSource): boolean {
return this.authService.hasPermission(AppPermission.DeletePrefillingSource) && prefillingSource?.belongsToCurrentTenant && prefillingSource?.isActive === IsActive.Active;
}
protected initializeLookup(): PrefillingSourceLookup {
const lookup = new PrefillingSourceLookup();
lookup.metadata = { countAll: true };

View File

@ -84,10 +84,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/reference-type/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/reference-type/', row.id])">
<mat-icon>edit</mat-icon>{{'REFERENCE-TYPE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'REFERENCE-TYPE-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -23,6 +23,7 @@ import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './reference-type-listing.component.html',
@ -72,6 +73,14 @@ export class ReferenceTypeListingComponent extends BaseListingComponent<Referenc
super.ngOnInit();
}
protected canEdit(referenceType: ReferenceType): boolean {
return this.authService.hasPermission(AppPermission.EditReferenceType) && referenceType?.belongsToCurrentTenant && referenceType?.isActive === IsActive.Active;
}
protected canDelete(referenceType: ReferenceType): boolean {
return this.authService.hasPermission(AppPermission.DeleteReferenceType) && referenceType?.belongsToCurrentTenant && referenceType?.isActive === IsActive.Active;
}
protected initializeLookup(): ReferenceTypeLookup {
const lookup = new ReferenceTypeLookup();
lookup.metadata = { countAll: true };

View File

@ -105,10 +105,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/references/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/references/', row.id])">
<mat-icon>edit</mat-icon>{{'REFERENCE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'REFERENCE-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -25,6 +25,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './reference-listing.component.html',
@ -78,6 +79,14 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
super.ngOnInit();
}
protected canEdit(reference: Reference): boolean {
return this.authService.hasPermission(AppPermission.EditReference) && reference?.belongsToCurrentTenant && reference?.isActive === IsActive.Active;
}
protected canDelete(reference: Reference): boolean {
return this.authService.hasPermission(AppPermission.DeleteReference) && reference?.belongsToCurrentTenant && reference?.isActive === IsActive.Active;
}
protected initializeLookup(): ReferenceLookup {
const lookup = new ReferenceLookup();
lookup.metadata = { countAll: true };

View File

@ -84,10 +84,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/tenants/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/tenants/', row.id])">
<mat-icon>edit</mat-icon>{{'TENANT-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'TENANT-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -23,6 +23,7 @@ import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './tenant-listing.component.html',
@ -72,6 +73,14 @@ export class TenantListingComponent extends BaseListingComponent<Tenant, TenantL
super.ngOnInit();
}
protected canEdit(tenant: Tenant): boolean {
return this.authService.hasPermission(AppPermission.EditTenant) && tenant?.isActive === IsActive.Active;
}
protected canDelete(tenant: Tenant): boolean {
return this.authService.hasPermission(AppPermission.DeleteTenant) && tenant?.isActive === IsActive.Active;
}
protected initializeLookup(): TenantLookup {
const lookup = new TenantLookup();
lookup.metadata = { countAll: true };

View File

@ -84,10 +84,10 @@
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="routerUtils.generateUrl(['/usage-limits/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/usage-limits/', row.id])">
<mat-icon>edit</mat-icon>{{'USAGE-LIMIT-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'USAGE-LIMIT-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -25,6 +25,7 @@ import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { UsageLimitTargetMetricPipe } from '@common/formatting/pipes/usage-limits-target-metric.pipe';
import { UsageLimitTargetMetric } from '@app/core/common/enum/usage-limit-target-metric';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './usage-limit-listing.component.html',
@ -76,6 +77,14 @@ export class UsageLimitListingComponent extends BaseListingComponent<UsageLimit,
super.ngOnInit();
}
protected canEdit(usageLimit: UsageLimit): boolean {
return this.authService.hasPermission(AppPermission.EditUsageLimit) && usageLimit?.belongsToCurrentTenant && usageLimit?.isActive === IsActive.Active;
}
protected canDelete(usageLimit: UsageLimit): boolean {
return this.authService.hasPermission(AppPermission.DeleteUsageLimit) && usageLimit?.belongsToCurrentTenant && usageLimit?.isActive === IsActive.Active;
}
protected initializeLookup(): UsageLimitLookup {
const lookup = new UsageLimitLookup();
lookup.metadata = { countAll: true };

View File

@ -92,16 +92,16 @@
</ng-template>
<ng-template #actions let-row="row" let-item>
<div *ngIf="!isDeleted(row)" class="row" (click)="$event.stopPropagation()">
<div *ngIf="canEdit(row) || canDelete(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 mat-menu-item [routerLink]="routerUtils.generateUrl(['/notification-templates/', row.id])">
<button *ngIf="canEdit(row)" mat-menu-item [routerLink]="routerUtils.generateUrl(['/notification-templates/', row.id])">
<mat-icon>edit</mat-icon>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -27,6 +27,7 @@ import { Language } from '@app/core/model/language/language';
import { NotificationTypePipe } from '@common/formatting/pipes/notification-type.pipe';
import { IsActive } from '@notification-service/core/enum/is-active.enum';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './notification-template-listing.component.html',
@ -77,6 +78,14 @@ export class NotificationTemplateListingComponent extends BaseListingComponent<N
super.ngOnInit();
}
protected canEdit(notificationTemplate: NotificationTemplate): boolean {
return this.authService.hasPermission(AppPermission.EditNotificationTemplate) && notificationTemplate?.isActive === IsActive.Active;
}
protected canDelete(notificationTemplate: NotificationTemplate): boolean {
return this.authService.hasPermission(AppPermission.DeleteNotificationTemplate) && notificationTemplate?.isActive === IsActive.Active;
}
protected initializeLookup(): NotificationTemplateLookup {
const lookup = new NotificationTemplateLookup();
lookup.metadata = { countAll: true };

View File

@ -80,13 +80,13 @@
</ng-template>
<ng-template #actions let-row="row" let-item>
<div *ngIf="!isDeleted(row)" class="row" (click)="$event.stopPropagation()">
<div *ngIf="canDelete(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 mat-menu-item (click)="deleteType(row.id)">
<button *ngIf="canDelete(row)" mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'NOTIFICATION-SERVICE.NOTIFICATION-LISTING.ACTIONS.DELETE' | translate}}
</button>

View File

@ -27,6 +27,7 @@ import { NotificationTrackingStatePipe } from '@common/formatting/pipes/notifica
import { NotificationTrackingProcessPipe } from '@common/formatting/pipes/notification-tracking-process.pipe';
import { IsActive } from '@notification-service/core/enum/is-active.enum';
import { DataTableDateTimeFormatPipe } from '@app/core/pipes/date-time-format.pipe';
import { AppPermission } from '@app/core/common/enum/permission.enum';
@Component({
templateUrl: './notification-listing.component.html',
@ -83,6 +84,10 @@ export class NotificationListingComponent extends BaseListingComponent<Notificat
super.ngOnInit();
}
protected canDelete(notification: Notification): boolean {
return notification?.isActive === IsActive?.Active;
}
protected initializeLookup(): NotificationLookup {
const lookup = new NotificationLookup();
lookup.metadata = { countAll: true };