From dceeb3500b5da8880218a9aaba87dd7cfa6f1484 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 28 Oct 2020 18:21:39 +0100 Subject: [PATCH] FEAT #13271 TIME 0:15 get real count filter --- .../app/search/filter-tool/filter-tool.component.html | 8 +++++--- .../app/search/filter-tool/filter-tool.component.ts | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/frontend/app/search/filter-tool/filter-tool.component.html b/src/frontend/app/search/filter-tool/filter-tool.component.html index 9f04c61b4b4..3f592fa24e8 100644 --- a/src/frontend/app/search/filter-tool/filter-tool.component.html +++ b/src/frontend/app/search/filter-tool/filter-tool.component.html @@ -5,8 +5,10 @@ </mat-panel-title> </mat-expansion-panel-header> <mat-selection-list #filterList *ngFor="let filterKey of filters | keyvalue" class="filter-list"> - <div class="catGroupTitle">{{'lang.'+filterKey.key | translate}} ({{filters[filterKey.key]['values'].length}})</div> - <mat-divider style="width: 80%;"></mat-divider> + <ng-container *ngIf="getRealCount(filterKey.key) > 0"> + <div class="catGroupTitle">{{'lang.'+filterKey.key | translate}} ({{getRealCount(filterKey.key)}})</div> + <mat-divider style="width: 80%;"></mat-divider> + </ng-container> <ng-container *ngFor="let cat of filters[filterKey.key]['values'];let i=index"> <ng-container *ngIf="cat.count > 0 || (cat.count === 0 && cat.selected)"> <mat-list-option color="primary" class="catContent" *ngIf="i < 5 || filters[filterKey.key]['expand']" (click)="toggleFilter(filterKey.key,i)" [selected]="cat.selected" checkboxPosition="before" [disabled]="isLoadingResults"> @@ -14,6 +16,6 @@ </mat-list-option> </ng-container> </ng-container> - <button mat-button *ngIf="filters[filterKey.key]['values'].length > 5" style="width:100%;" color="primary" (click)="toggleDisplay(filterKey.key)">{{filters[filterKey.key]['expand'] ? ('lang.less' | translate) : ('lang.more' | translate) }}<mat-icon style="height:auto;" class="fas" [class.fa-chevron-down]="!filters[filterKey.key]['expand']" [class.fa-chevron-up]="filters[filterKey.key]['expand']"></mat-icon></button> + <button mat-button *ngIf="getRealCount(filterKey.key) > 5" style="width:100%;" color="primary" (click)="toggleDisplay(filterKey.key)">{{filters[filterKey.key]['expand'] ? ('lang.less' | translate) : ('lang.more' | translate) }}<mat-icon style="height:auto;" class="fas" [class.fa-chevron-down]="!filters[filterKey.key]['expand']" [class.fa-chevron-up]="filters[filterKey.key]['expand']"></mat-icon></button> </mat-selection-list> </mat-expansion-panel> diff --git a/src/frontend/app/search/filter-tool/filter-tool.component.ts b/src/frontend/app/search/filter-tool/filter-tool.component.ts index e51e2b4b449..cb6ba8b5461 100644 --- a/src/frontend/app/search/filter-tool/filter-tool.component.ts +++ b/src/frontend/app/search/filter-tool/filter-tool.component.ts @@ -36,4 +36,8 @@ export class FilterToolComponent implements OnInit { toggleDisplay(key: string) { this.filters[key]['expand'] = !this.filters[key]['expand']; } + + getRealCount(key: string) { + return this.filters[key]['values'].filter((item: any) => item.count > 0 || (item.count === 0 && item.selected)).length; + } } -- GitLab