From 67fc1ee7172db7218818407ffc738a3a2d5c866c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Tue, 11 Jun 2019 15:17:09 +0200 Subject: [PATCH] Fix comment counter --- .../shared/comment-list/comment-list.component.html | 6 +++--- .../shared/comment-list/comment-list.component.scss | 9 ++++++++- .../shared/comment-list/comment-list.component.ts | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/components/shared/comment-list/comment-list.component.html b/src/app/components/shared/comment-list/comment-list.component.html index b188318c4..6ffad6e3f 100644 --- a/src/app/components/shared/comment-list/comment-list.component.html +++ b/src/app/components/shared/comment-list/comment-list.component.html @@ -14,8 +14,8 @@ <div class="button-bar" fxLayoutAlign="center center"> <div *ngIf="comments && comments.length > 0"> <mat-chip-list> - <mat-chip class="comment-counter" *ngIf="(!filteredComments) || (comments.length === filteredComments.length)">{{comments.length}}</mat-chip> - <mat-chip class="comment-counter" *ngIf="(filteredComments) && (comments.length > filteredComments.length)">{{filteredComments.length}}</mat-chip> + <mat-chip class="counter" *ngIf="comments && !hideCommentsList">{{comments.length}}</mat-chip> + <mat-chip class="counter counter-filtered" *ngIf="filteredComments && hideCommentsList">{{filteredComments.length}}</mat-chip> </mat-chip-list> </div> @@ -67,7 +67,7 @@ <mat-icon [ngClass]="{unread: 'unread-icon'}[currentFilter]">visibility_off</mat-icon> </button> - <button mat-icon-button (focus)="hideCommentsList=false" (click)="sortComments(currentSort)"> + <button mat-icon-button (focus)="hideCommentsList=false" (click)="sortComments(currentSort); filterComments('')"> <mat-icon>close</mat-icon> </button> </div> diff --git a/src/app/components/shared/comment-list/comment-list.component.scss b/src/app/components/shared/comment-list/comment-list.component.scss index 1c6e49a66..648f96db1 100644 --- a/src/app/components/shared/comment-list/comment-list.component.scss +++ b/src/app/components/shared/comment-list/comment-list.component.scss @@ -80,8 +80,15 @@ h4 { color: var(--yellow); } -.comment-counter { +.counter { font-size: 18pt; + background-color: var(--primary); + color: var(--on-primary); +} + +.counter-filtered { + background-color: var(--secondary); + color: var(--on-secondary); } .up { 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 4ff0c4579..daa3e2fe4 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -182,6 +182,10 @@ export class CommentListComponent implements OnInit { filterComments(type: string): void { this.currentFilter = type; + if (type === '') { + this.filteredComments = this.comments; + return; + } this.filteredComments = this.comments.filter(c => { switch (type) { case this.correct: -- GitLab