|
@ -57,10 +57,8 @@ export class TransactionsTableComponent |
|
|
public dataSource: MatTableDataSource<OrderWithAccount> = new MatTableDataSource(); |
|
|
public dataSource: MatTableDataSource<OrderWithAccount> = new MatTableDataSource(); |
|
|
public defaultDateFormat = DEFAULT_DATE_FORMAT; |
|
|
public defaultDateFormat = DEFAULT_DATE_FORMAT; |
|
|
public displayedColumns = []; |
|
|
public displayedColumns = []; |
|
|
public filteredTransactions$: Subject<string[]> = new BehaviorSubject([]); |
|
|
public filters$: Subject<string[]> = new BehaviorSubject([]); |
|
|
public filteredTransactions: Observable< |
|
|
public filters: Observable<string[]> = this.filters$.asObservable(); |
|
|
string[] |
|
|
|
|
|
> = this.filteredTransactions$.asObservable(); |
|
|
|
|
|
public isLoading = true; |
|
|
public isLoading = true; |
|
|
public placeholder = ''; |
|
|
public placeholder = ''; |
|
|
public routeQueryParams: Subscription; |
|
|
public routeQueryParams: Subscription; |
|
@ -68,7 +66,7 @@ export class TransactionsTableComponent |
|
|
public searchKeywords: string[] = []; |
|
|
public searchKeywords: string[] = []; |
|
|
public separatorKeysCodes: number[] = [ENTER, COMMA]; |
|
|
public separatorKeysCodes: number[] = [ENTER, COMMA]; |
|
|
|
|
|
|
|
|
private allFilteredTransactions: string[]; |
|
|
private allFilters: string[]; |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
@ -90,13 +88,13 @@ export class TransactionsTableComponent |
|
|
this.searchControl.valueChanges.subscribe((keyword) => { |
|
|
this.searchControl.valueChanges.subscribe((keyword) => { |
|
|
if (keyword) { |
|
|
if (keyword) { |
|
|
const filterValue = keyword.toLowerCase(); |
|
|
const filterValue = keyword.toLowerCase(); |
|
|
this.filteredTransactions$.next( |
|
|
this.filters$.next( |
|
|
this.allFilteredTransactions.filter( |
|
|
this.allFilters.filter( |
|
|
(filter) => filter.toLowerCase().indexOf(filterValue) === 0 |
|
|
(filter) => filter.toLowerCase().indexOf(filterValue) === 0 |
|
|
) |
|
|
) |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
this.filteredTransactions$.next(this.allFilteredTransactions); |
|
|
this.filters$.next(this.allFilters); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -239,13 +237,13 @@ export class TransactionsTableComponent |
|
|
this.placeholder = |
|
|
this.placeholder = |
|
|
lowercaseSearchKeywords.length <= 0 ? SEARCH_PLACEHOLDER : ''; |
|
|
lowercaseSearchKeywords.length <= 0 ? SEARCH_PLACEHOLDER : ''; |
|
|
|
|
|
|
|
|
this.allFilteredTransactions = this.getSearchableFieldValues( |
|
|
this.allFilters = this.getSearchableFieldValues(this.transactions).filter( |
|
|
this.transactions |
|
|
(item) => { |
|
|
).filter((item) => { |
|
|
return !lowercaseSearchKeywords.includes(item.trim().toLowerCase()); |
|
|
return !lowercaseSearchKeywords.includes(item.trim().toLowerCase()); |
|
|
} |
|
|
}); |
|
|
); |
|
|
|
|
|
|
|
|
this.filteredTransactions$.next(this.allFilteredTransactions); |
|
|
this.filters$.next(this.allFilters); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getSearchableFieldValues(transactions: OrderWithAccount[]): string[] { |
|
|
private getSearchableFieldValues(transactions: OrderWithAccount[]): string[] { |
|
|