permissions resolver fix

This commit is contained in:
Sofia Papacharalampous 2024-07-16 10:50:20 +03:00
parent b81903a735
commit 27b6643180
3 changed files with 23 additions and 18 deletions

View File

@ -46,14 +46,6 @@ export class DescriptionEditorEntityResolver extends BaseEditorResolver {
] ]
} }
public static permissionLookupFields(): string[] {
return [
nameof<Description>(x => x.id),
[nameof<Description>(x => x.plan), nameof<Plan>(x => x.id)].join('.'),
[nameof<Description>(x => x.planDescriptionTemplate), nameof<PlanDescriptionTemplate>(x => x.sectionId)].join('.'),
]
}
public static descriptionLookupFields(): string[] { public static descriptionLookupFields(): string[] {
return [ return [
...BaseEditorResolver.lookupFields(), ...BaseEditorResolver.lookupFields(),

View File

@ -1,16 +1,14 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; 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 { Description, DescriptionSectionPermissionResolver } from '@app/core/model/description/description';
import { DescriptionService } from '@app/core/services/description/description.service'; 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 { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { BaseEditorResolver } from '@common/base/base-editor.resolver';
import { Guid } from '@common/types/guid'; import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core'; import { mergeMap, takeUntil, tap } from 'rxjs/operators';
import { concatMap, map, mergeMap, takeUntil, tap } from 'rxjs/operators';
import { DescriptionEditorEntityResolver } from './description-editor-entity.resolver';
import { AppPermission } from '@app/core/common/enum/permission.enum'; 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() @Injectable()
export class DescriptionEditorPermissionsResolver extends BaseEditorResolver { export class DescriptionEditorPermissionsResolver extends BaseEditorResolver {
@ -18,16 +16,22 @@ export class DescriptionEditorPermissionsResolver extends BaseEditorResolver {
constructor( constructor(
private descriptionService: DescriptionService, private descriptionService: DescriptionService,
private breadcrumbService: BreadcrumbService, private breadcrumbService: BreadcrumbService,
private language: TranslateService,
private planService: PlanService
) { ) {
super(); super();
} }
public static permissionLookupFields(): string[] {
return [
nameof<Description>(x => x.id),
[nameof<Description>(x => x.plan), nameof<Plan>(x => x.id)].join('.'),
[nameof<Description>(x => x.planDescriptionTemplate), nameof<PlanDescriptionTemplate>(x => x.sectionId)].join('.'),
]
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const fields = [ const fields = [
...DescriptionEditorEntityResolver.permissionLookupFields() ...DescriptionEditorPermissionsResolver.permissionLookupFields()
]; ];
const id = route.paramMap.get('id'); const id = route.paramMap.get('id');
const planId = route.paramMap.get('planId'); const planId = route.paramMap.get('planId');

View File

@ -8,7 +8,9 @@ import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { BaseEditorResolver } from '@common/base/base-editor.resolver';
import { Guid } from '@common/types/guid'; import { Guid } from '@common/types/guid';
import { mergeMap, takeUntil, tap } from 'rxjs/operators'; 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() @Injectable()
export class PlanEditorPermissionsResolver extends BaseEditorResolver { export class PlanEditorPermissionsResolver extends BaseEditorResolver {
@ -20,10 +22,17 @@ export class PlanEditorPermissionsResolver extends BaseEditorResolver {
super(); super();
} }
public static permissionLookupFields(): string[] {
return [
nameof<Plan>(x => x.id),
[nameof<Plan>(x => x.blueprint), nameof<PlanBlueprint>(x => x.definition), nameof<PlanBlueprintDefinition>(x => x.sections), nameof<PlanBlueprintDefinitionSection>(x => x.id)].join('.'),
]
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const fields = [ const fields = [
...PlanEditorEntityResolver.lookupFields() ...PlanEditorPermissionsResolver.permissionLookupFields()
]; ];
const id = route.paramMap.get('id'); const id = route.paramMap.get('id');
if (id != null) { if (id != null) {