From 27b6643180a17278bf2e16938fe9a45ad7401eb1 Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Tue, 16 Jul 2024 10:50:20 +0300 Subject: [PATCH] permissions resolver fix --- .../description-editor-entity.resolver.ts | 8 -------- ...description-editor-permissions.resolver.ts | 20 +++++++++++-------- .../plan-editor-permissions.resolver.ts | 13 ++++++++++-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts index 379d45ccf..9b9669e60 100644 --- a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts +++ b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts @@ -46,14 +46,6 @@ export class DescriptionEditorEntityResolver extends BaseEditorResolver { ] } - public static permissionLookupFields(): string[] { - return [ - nameof(x => x.id), - [nameof(x => x.plan), nameof(x => x.id)].join('.'), - [nameof(x => x.planDescriptionTemplate), nameof(x => x.sectionId)].join('.'), - ] - } - public static descriptionLookupFields(): string[] { return [ ...BaseEditorResolver.lookupFields(), diff --git a/frontend/src/app/ui/description/editor/resolvers/description-editor-permissions.resolver.ts b/frontend/src/app/ui/description/editor/resolvers/description-editor-permissions.resolver.ts index 1dc99a1dd..2ad995470 100644 --- a/frontend/src/app/ui/description/editor/resolvers/description-editor-permissions.resolver.ts +++ b/frontend/src/app/ui/description/editor/resolvers/description-editor-permissions.resolver.ts @@ -1,16 +1,14 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { Description, DescriptionSectionPermissionResolver } from '@app/core/model/description/description'; import { DescriptionService } from '@app/core/services/description/description.service'; -import { PlanService } from '@app/core/services/plan/plan.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import { concatMap, map, mergeMap, takeUntil, tap } from 'rxjs/operators'; -import { DescriptionEditorEntityResolver } from './description-editor-entity.resolver'; +import { mergeMap, takeUntil, tap } from 'rxjs/operators'; import { AppPermission } from '@app/core/common/enum/permission.enum'; +import { nameof } from 'ts-simple-nameof'; +import { Plan, PlanDescriptionTemplate } from '@app/core/model/plan/plan'; @Injectable() export class DescriptionEditorPermissionsResolver extends BaseEditorResolver { @@ -18,16 +16,22 @@ export class DescriptionEditorPermissionsResolver extends BaseEditorResolver { constructor( private descriptionService: DescriptionService, private breadcrumbService: BreadcrumbService, - private language: TranslateService, - private planService: PlanService ) { super(); } + public static permissionLookupFields(): string[] { + return [ + nameof(x => x.id), + [nameof(x => x.plan), nameof(x => x.id)].join('.'), + [nameof(x => x.planDescriptionTemplate), nameof(x => x.sectionId)].join('.'), + ] + } + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { const fields = [ - ...DescriptionEditorEntityResolver.permissionLookupFields() + ...DescriptionEditorPermissionsResolver.permissionLookupFields() ]; const id = route.paramMap.get('id'); const planId = route.paramMap.get('planId'); diff --git a/frontend/src/app/ui/plan/plan-editor-blueprint/resolvers/plan-editor-permissions.resolver.ts b/frontend/src/app/ui/plan/plan-editor-blueprint/resolvers/plan-editor-permissions.resolver.ts index 3d1e60f33..c3d1d7684 100644 --- a/frontend/src/app/ui/plan/plan-editor-blueprint/resolvers/plan-editor-permissions.resolver.ts +++ b/frontend/src/app/ui/plan/plan-editor-blueprint/resolvers/plan-editor-permissions.resolver.ts @@ -8,7 +8,9 @@ import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { Guid } from '@common/types/guid'; import { mergeMap, takeUntil, tap } from 'rxjs/operators'; -import { PlanEditorEntityResolver } from './plan-editor-enitity.resolver'; +import { Plan } from '@app/core/model/plan/plan'; +import { nameof } from 'ts-simple-nameof'; +import { PlanBlueprint, PlanBlueprintDefinition, PlanBlueprintDefinitionSection } from '@app/core/model/plan-blueprint/plan-blueprint'; @Injectable() export class PlanEditorPermissionsResolver extends BaseEditorResolver { @@ -20,10 +22,17 @@ export class PlanEditorPermissionsResolver extends BaseEditorResolver { super(); } + public static permissionLookupFields(): string[] { + return [ + nameof(x => x.id), + [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), + ] + } + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { const fields = [ - ...PlanEditorEntityResolver.lookupFields() + ...PlanEditorPermissionsResolver.permissionLookupFields() ]; const id = route.paramMap.get('id'); if (id != null) {