From 6a969883ada4095d4a9b0314299a1aba610078d1 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Tue, 29 Jan 2019 12:11:11 +0100 Subject: [PATCH] acknowledge string filter - display correct number of show entries - all bulk actions should only apply to filtered data - fix user group filter --- .../app/core/services/filter-list.service.ts | 2 +- .../os-sort-filter-bar.component.html | 2 +- .../os-sort-filter-bar.component.ts | 20 ++++++++++++++++++- .../agenda-list/agenda-list.component.html | 3 +-- .../agenda-list/agenda-list.component.ts | 2 +- .../assignment-list.component.html | 2 +- client/src/app/site/base/list-view-base.ts | 11 ++++++++-- .../mediafile-list.component.html | 2 +- .../motion-list/motion-list.component.html | 1 + .../motion-list/motion-list.component.ts | 8 ++++++-- .../user-list/user-list.component.html | 1 + .../user-list/user-list.component.ts | 2 +- .../services/user-filter-list.service.ts | 8 ++++++-- 13 files changed, 49 insertions(+), 15 deletions(-) diff --git a/client/src/app/core/services/filter-list.service.ts b/client/src/app/core/services/filter-list.service.ts index fc3be6317..5847db210 100644 --- a/client/src/app/core/services/filter-list.service.ts +++ b/client/src/app/core/services/filter-list.service.ts @@ -67,7 +67,7 @@ export abstract class FilterListService
- {{ filterService.filteredCount }} of + {{ displayedCount }} of  {{ filterService.totalCount }}
diff --git a/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.ts b/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.ts index 1081cd5c0..bb2f0c157 100644 --- a/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.ts +++ b/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.ts @@ -19,7 +19,7 @@ import { ViewportService } from '../../../core/services/viewport.service'; * * ```html * + * (searchFieldChange)="searchFilter($event)" [filterCount]="filteredCount"> * * ``` */ @@ -35,6 +35,12 @@ export class OsSortFilterBarComponent { @Input() public sortService: SortListService; + /** Optional number to overwrite the display of the filtered data count, if any additional filters + * (e.g. the angular search bar) are applied on top of these filters + */ + @Input() + public filterCount: number; + /** * The currently active filter service for the list view. It is supposed to * be a FilterListService extendingFilterListService. @@ -61,6 +67,18 @@ export class OsSortFilterBarComponent { */ public isSearchBar = false; + /** + * Return the amount of data passing filters. Priorizes the override in {@link filterCount} over + * the information from the filterService + */ + public get displayedCount(): number { + if (this.filterCount === undefined || this.filterCount === null) { + return this.filterService.filterCount; + } else { + return this.filterCount; + } + } + /** * Constructor. Also creates a filtermenu component and a bottomSheet * @param translate diff --git a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html index 786de9f0c..172eab33d 100644 --- a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html +++ b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html @@ -13,8 +13,7 @@
- - + diff --git a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts index e3cf8c050..5aafa8a6d 100644 --- a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts +++ b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts @@ -225,6 +225,6 @@ export class AgendaListComponent extends ListViewBaseComponent impleme * Export all items as CSV */ public csvExportItemList(): void { - this.csvExport.exportItemList(this.dataSource.data); + this.csvExport.exportItemList(this.dataSource.filteredData); } } diff --git a/client/src/app/site/assignments/assignment-list/assignment-list.component.html b/client/src/app/site/assignments/assignment-list/assignment-list.component.html index c161b0716..07207f1e0 100644 --- a/client/src/app/site/assignments/assignment-list/assignment-list.component.html +++ b/client/src/app/site/assignments/assignment-list/assignment-list.component.html @@ -16,7 +16,7 @@ - diff --git a/client/src/app/site/base/list-view-base.ts b/client/src/app/site/base/list-view-base.ts index 022a11861..e21ced4f3 100644 --- a/client/src/app/site/base/list-view-base.ts +++ b/client/src/app/site/base/list-view-base.ts @@ -46,6 +46,13 @@ export abstract class ListViewBaseComponent extends Bas @ViewChild(MatSort) protected sort: MatSort; + /** + * @returns the amount of currently dispalyed items (only showing items that pass all filters) + */ + public get filteredCount(): number { + return this.dataSource.filteredData.length; + } + /** * Constructor for list view bases * @param titleService the title serivce @@ -132,7 +139,7 @@ export abstract class ListViewBaseComponent extends Bas * Select all files in the current data source */ public selectAll(): void { - this.selectedRows = this.dataSource.data; + this.selectedRows = this.dataSource.filteredData; } public deselectAll(): void { @@ -175,7 +182,7 @@ export abstract class ListViewBaseComponent extends Bas protected checkSelection(): void { const newSelection = []; this.selectedRows.forEach(selectedrow => { - const newrow = this.dataSource.data.find(item => item.id === selectedrow.id); + const newrow = this.dataSource.filteredData.find(item => item.id === selectedrow.id); if (newrow) { newSelection.push(newrow); } diff --git a/client/src/app/site/mediafiles/components/mediafile-list/mediafile-list.component.html b/client/src/app/site/mediafiles/components/mediafile-list/mediafile-list.component.html index e511ca728..e38e01280 100644 --- a/client/src/app/site/mediafiles/components/mediafile-list/mediafile-list.component.html +++ b/client/src/app/site/mediafiles/components/mediafile-list/mediafile-list.component.html @@ -49,7 +49,7 @@ - diff --git a/client/src/app/site/motions/components/motion-list/motion-list.component.html b/client/src/app/site/motions/components/motion-list/motion-list.component.html index 95fdf776a..25c2aaf90 100644 --- a/client/src/app/site/motions/components/motion-list/motion-list.component.html +++ b/client/src/app/site/motions/components/motion-list/motion-list.component.html @@ -18,6 +18,7 @@ imple if (result && result.format) { if (result.format === 'pdf') { this.pdfExport.exportMotionCatalog( - this.dataSource.data, + this.dataSource.filteredData, result.lnMode, result.crMode, result.content, result.metaInfo ); } else if (result.format === 'csv') { - this.motionCsvExport.exportMotionList(this.dataSource.data, result.content, result.metaInfo); + this.motionCsvExport.exportMotionList( + this.dataSource.filteredData, + result.content, + result.metaInfo + ); } } }); diff --git a/client/src/app/site/users/components/user-list/user-list.component.html b/client/src/app/site/users/components/user-list/user-list.component.html index 59b0034e1..e628120ec 100644 --- a/client/src/app/site/users/components/user-list/user-list.component.html +++ b/client/src/app/site/users/components/user-list/user-list.component.html @@ -16,6 +16,7 @@ implement */ public csvExportUserList(): void { this.csvExport.export( - this.dataSource.data, + this.dataSource.filteredData, [ { property: 'title' }, { property: 'first_name', label: 'Given name' }, diff --git a/client/src/app/site/users/services/user-filter-list.service.ts b/client/src/app/site/users/services/user-filter-list.service.ts index 8ee788e8a..2422f0447 100644 --- a/client/src/app/site/users/services/user-filter-list.service.ts +++ b/client/src/app/site/users/services/user-filter-list.service.ts @@ -15,7 +15,7 @@ export class UserFilterListService extends FilterListService { private userGroupFilterOptions = { isActive: false, - property: 'group', + property: 'groups_id', label: 'User Group', options: [] }; @@ -60,12 +60,16 @@ export class UserFilterListService extends FilterListService { this.subscribeGroups(); } + /** + * Updates the filter according to existing groups. + * TODO: Users with only the 'standard' group set appear in the model as items without groups_id. 'Standard' filter is broken + */ public subscribeGroups(): void { this.groupRepo.getViewModelListObservable().subscribe(groups => { const groupOptions = []; groups.forEach(group => { groupOptions.push({ - condition: group.name, + condition: group.id, label: group.name, isActive: false });