From afda3e03ec778e4501bc5c9fa21da9a72722b07d Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Wed, 19 Jun 2019 11:38:14 +0200 Subject: [PATCH] Add Filter predicate for ID All List View Tables can get custom filter predicates. Per default, they now filter their primitive content as well as their ID --- .../list-view-table.component.ts | 49 ++++++++++++++++++- .../motion-list/motion-list.component.html | 26 +++++++--- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/client/src/app/shared/components/list-view-table/list-view-table.component.ts b/client/src/app/shared/components/list-view-table/list-view-table.component.ts index 402eb4a37..6acb9e5c2 100644 --- a/client/src/app/shared/components/list-view-table/list-view-table.component.ts +++ b/client/src/app/shared/components/list-view-table/list-view-table.component.ts @@ -186,6 +186,11 @@ export class ListViewTableComponent { + if (!this.inputValue) { + return true; + } + + if (this.inputValue) { + const trimmedInput = this.inputValue.trim().toLowerCase(); + const idString = '' + item.id; + const foundId = + idString + .trim() + .toLowerCase() + .indexOf(trimmedInput) !== -1; + if (foundId) { + return true; + } + + for (const column of this.columns) { + const col = this.dataSource.hostGrid.columnApi.findColumn(column.prop); + const value = col.getValue(item); + + if (!!value) { + const valueAsString = '' + value; + const foundValue = + valueAsString + .trim() + .toLocaleLowerCase() + .indexOf(trimmedInput) !== -1; + + if (foundValue) { + return true; + } + } + } + } + }; + + this.dataSource.setFilter(filterPredicate); + // inform listening components about changes in the data source this.dataSource.onSourceChanged.subscribe(() => { this.dataSourceChange.next(this.dataSource); @@ -341,8 +385,9 @@ export class ListViewTableComponent -
- by {{ motion.submitters }} +
+ + by + {{ motion.submitters }} + + - · + + · + Sequential number {{ motion.id }} @@ -104,12 +110,14 @@
- {{ motion.category.prefixedNameWithParents }} + + {{ motion.category.prefixedNameWithParents }} +
- {{ - motion.motion_block.title - }} + + {{ motion.motion_block.title }} +
@@ -153,7 +161,9 @@
- {{ motion.category.prefixedNameWithParents }} + + {{ motion.category.prefixedNameWithParents }} +