diff --git a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.html b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.html index 71bbcd7ad1c9768661ed69bfb11a036987e781a4..7bd79f6710b2047b1bf7bd56b2e13514686d7d16 100644 --- a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.html +++ b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.html @@ -67,8 +67,9 @@ </button> <div *ngIf="!isLoading"> - <app-comment *ngFor="let current of comments" [comment]="current" [userRole]="user.role" - [parseVote]="getVote(current)" [moderator]="true"></app-comment> + <app-comment *ngFor="let current of hideCommentsList ? filteredComments : comments" [comment]="current" [userRole]="user.role" + [parseVote]="getVote(current)" [moderator]="true" (clickedUserNumber)="clickedUserNumber($event)"> + </app-comment> </div> <div *ngIf="comments && comments.length < 1 && !isLoading" fxLayout="row" fxLayoutAlign="center center" diff --git a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts index 218a713883e88cbaa422351b10f101eabd45c9d1..4e454b7407b105fd4af3ccadb75c80184ccfdf3d 100644 --- a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts +++ b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts @@ -44,6 +44,7 @@ export class ModeratorCommentListComponent implements OnInit { correct = 'correct'; wrong = 'wrong'; ack = 'ack'; + userNumber = 'userNumber'; currentFilter = ''; commentVoteMap = new Map<string, Vote>(); scroll = false; @@ -204,6 +205,8 @@ export class ModeratorCommentListComponent implements OnInit { c.body = payload.body; c.id = payload.id; c.timestamp = payload.timestamp; + c.creatorId = payload.creatorId; + c.userNumber = this.commentService.hashCode(c.creatorId); this.comments = this.comments.concat(c); break; } @@ -212,7 +215,7 @@ export class ModeratorCommentListComponent implements OnInit { this.searchComments(); } - filterComments(type: string): void { + filterComments(type: string, compare?: any): void { this.currentFilter = type; if (type === '') { this.filteredComments = this.comments; @@ -230,11 +233,18 @@ export class ModeratorCommentListComponent implements OnInit { return c.read; case this.unread: return !c.read; + case this.userNumber: + return c.userNumber === compare; } }); + this.hideCommentsList = true; this.sortComments(this.currentSort); } + clickedUserNumber(usrNumber: number): void { + this.filterComments(this.userNumber, usrNumber); + } + sort(array: any[], type: string): void { array.sort((a, b) => { if (type === this.voteasc) {