From 7152be7fa15ac3ad50793ec5be15a097a3471d19 Mon Sep 17 00:00:00 2001 From: mantovanig Date: Thu, 6 May 2021 11:47:48 +0200 Subject: [PATCH] fix: add filterPredicate on transactions table to filter by account name --- .../transactions-table.component.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/client/src/app/components/transactions-table/transactions-table.component.ts b/apps/client/src/app/components/transactions-table/transactions-table.component.ts index 4978701f4..0e2677d24 100644 --- a/apps/client/src/app/components/transactions-table/transactions-table.component.ts +++ b/apps/client/src/app/components/transactions-table/transactions-table.component.ts @@ -89,6 +89,17 @@ export class TransactionsTableComponent this.dataSource = new MatTableDataSource(this.transactions); this.dataSource.sort = this.sort; + this.dataSource.filterPredicate = (data, filter: string) => { + const accumulator = (currentTerm, key) => { + return key === 'Account' + ? currentTerm + data.Account.name + : currentTerm + data[key]; + }; + const dataStr = Object.keys(data).reduce(accumulator, '').toLowerCase(); + const transformedFilter = filter.trim().toLowerCase(); + return dataStr.indexOf(transformedFilter) !== -1; + }; + this.isLoading = false; } }