diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index d39cb3331b4999549d58b1f7d70c3c3189ca829c..d90260ac2c8fc4c243da687cecc8f11de237ad6f 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -52,16 +52,4 @@ export class CommentListComponent implements OnInit { this.isLoading = false; }); } - - setRead(comment: Comment): void { - this.comments.find(c => c.id === comment.id).read = !comment.read; - this.commentService.updateComment(comment).subscribe(); - } - - delete(comment: Comment): void { - this.comments = this.comments.filter(c => c !== comment); - this.commentService.deleteComment(comment.id).subscribe(room => { - this.notification.show(`Comment '${comment.subject}' successfully deleted.`); - }); - } } diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 9ce76d8696d34b723ece87dc5b3b57582e545921..24a9ea824ff980a303370a4e37043d980f5b0ba8 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -1,5 +1,15 @@ import { Component, Input, OnInit } from '@angular/core'; import { Comment } from '../../../models/comment'; +import { UserRole } from '../../../models/user-roles.enum'; +import { User } from '../../../models/user'; +import { AuthenticationService } from '../../../services/http/authentication.service'; +import { ActivatedRoute } from '@angular/router'; +import { RoomService } from '../../../services/http/room.service'; +import { Location } from '@angular/common'; +import { CommentService } from '../../../services/http/comment.service'; +import { NotificationService } from '../../../services/util/notification.service'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../../services/util/language.service'; @Component({ selector: 'app-comment', @@ -8,9 +18,37 @@ import { Comment } from '../../../models/comment'; }) export class CommentComponent implements OnInit { @Input() comment: Comment; - constructor() { } + userRoleTemp: any = UserRole.CREATOR; + userRole: UserRole; + user: User; + isLoading = true; + roomId: string; + roomShortId: string; + + constructor(protected authenticationService: AuthenticationService, + private route: ActivatedRoute, + private roomService: RoomService, + private location: Location, + private commentService: CommentService, + private notification: NotificationService, + private translateService: TranslateService, + protected langService: LanguageService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); } ngOnInit() { + this.userRole = this.authenticationService.getRole(); + this.user = this.authenticationService.getUser(); + this.roomShortId = this.route.snapshot.paramMap.get('roomId'); + this.roomId = localStorage.getItem(`roomId`); + this.translateService.use(localStorage.getItem('currentLang')); + } + setRead(comment: Comment): void { + this.commentService.updateComment(comment).subscribe(); } + delete(comment: Comment): void { + this.commentService.deleteComment(comment.id).subscribe(room => { + this.notification.show(`Comment '${comment.subject}' successfully deleted.`); + }); + } }