From 395bed13a3b8889b81a6016dab91e5d27cdd9dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@gmx.de> Date: Thu, 2 Apr 2020 14:50:55 +0200 Subject: [PATCH] Fix routing to question comment for moderators --- .../components/moderator/moderator-routing.module.ts | 4 ++-- .../components/shared/comment/comment.component.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/components/moderator/moderator-routing.module.ts b/src/app/components/moderator/moderator-routing.module.ts index 65cf488e9..63836d953 100644 --- a/src/app/components/moderator/moderator-routing.module.ts +++ b/src/app/components/moderator/moderator-routing.module.ts @@ -27,11 +27,11 @@ const routes: Routes = [ data: { roles: [UserRole.EXECUTIVE_MODERATOR] } }, { - path: 'room/:shortId/moderator/comment/:commentId', + path: 'room/:shortId/comment/:commentId', component: CommentAnswerComponent, canActivate: [AuthenticationGuard], data: { roles: [UserRole.EXECUTIVE_MODERATOR] } - }, + } ]; @NgModule({ diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index f50edb08a..debd2626a 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -45,6 +45,7 @@ export class CommentComponent implements OnInit { inAnswerView = false; currentVote: string; slideAnimationState = 'hidden'; + roleString: string; constructor(protected authenticationService: AuthenticationService, private route: ActivatedRoute, @@ -66,12 +67,15 @@ export class CommentComponent implements OnInit { switch (this.userRole) { case UserRole.PARTICIPANT.valueOf(): this.isStudent = true; + this.roleString = 'participant'; break; case UserRole.CREATOR.valueOf(): this.isCreator = true; + this.roleString = 'creator'; break; case UserRole.EXECUTIVE_MODERATOR.valueOf(): this.isModerator = true; + this.roleString = 'moderator'; } this.language = localStorage.getItem('currentLang'); this.translateService.use(this.language); @@ -155,8 +159,11 @@ export class CommentComponent implements OnInit { } answerComment() { - const url = this.location.path().slice(0, -1); - this.router.navigate([`${url}/${this.comment.id}`]); + let url: string; + this.route.params.subscribe(params => { + url = `${this.roleString}/room/${params['shortId']}/comment/${this.comment.id}`; + }); + this.router.navigate([url]); } delete(): void { -- GitLab