Skip to content
Snippets Groups Projects
Commit f85c2cd3 authored by Tom Käsler's avatar Tom Käsler
Browse files

Allow filtering for userid for moderator view

parent dab89952
No related merge requests found
......@@ -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"
......
......@@ -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) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment