Moved from tslint to eslint as tslint was depreciated.
Added prettier and also prettied all the typescript files using prettier ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
@@ -5,15 +5,17 @@ import { map, tap } from 'rxjs/operators';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { Account } from '../../core/account';
|
||||
|
||||
|
||||
export class AccountListDataSource extends DataSource<Account> {
|
||||
private filterValue: string;
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, private filter: Observable<string>, public data: Account[]) {
|
||||
constructor(
|
||||
private paginator: MatPaginator,
|
||||
private sort: MatSort,
|
||||
private filter: Observable<string>,
|
||||
public data: Account[],
|
||||
) {
|
||||
super();
|
||||
this.filter = filter.pipe(
|
||||
tap(x => this.filterValue = x)
|
||||
);
|
||||
this.filter = filter.pipe(tap((x) => (this.filterValue = x)));
|
||||
}
|
||||
|
||||
connect(): Observable<Account[]> {
|
||||
@@ -21,34 +23,39 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
observableOf(this.data),
|
||||
this.filter,
|
||||
this.paginator.page,
|
||||
this.sort.sortChange
|
||||
this.sort.sortChange,
|
||||
];
|
||||
|
||||
return merge(...dataMutations).pipe(
|
||||
map((x: any) => {
|
||||
return this.getFilteredData([...this.data]);
|
||||
}),
|
||||
tap((x: Account[]) => this.paginator.length = x.length)
|
||||
).pipe(
|
||||
map((x: any) => {
|
||||
return this.getPagedData(this.getSortedData(x));
|
||||
})
|
||||
);
|
||||
return merge(...dataMutations)
|
||||
.pipe(
|
||||
map((x: any) => {
|
||||
return this.getFilteredData([...this.data]);
|
||||
}),
|
||||
tap((x: Account[]) => (this.paginator.length = x.length)),
|
||||
)
|
||||
.pipe(
|
||||
map((x: any) => {
|
||||
return this.getPagedData(this.getSortedData(x));
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
|
||||
private getFilteredData(data: Account[]): Account[] {
|
||||
const filter = (this.filterValue === undefined) ? '' : this.filterValue;
|
||||
const filter = this.filterValue === undefined ? '' : this.filterValue;
|
||||
return filter.split(' ').reduce((p: Account[], c: string) => {
|
||||
return p.filter(x => {
|
||||
const accountString = (
|
||||
x.name + ' ' + x.type + ' ' + x.costCentre + (x.isActive ? ' active' : ' inactive')
|
||||
).toLowerCase();
|
||||
return accountString.indexOf(c) !== -1;
|
||||
}
|
||||
);
|
||||
return p.filter((x) => {
|
||||
const accountString = (
|
||||
x.name +
|
||||
' ' +
|
||||
x.type +
|
||||
' ' +
|
||||
x.costCentre +
|
||||
(x.isActive ? ' active' : ' inactive')
|
||||
).toLowerCase();
|
||||
return accountString.indexOf(c) !== -1;
|
||||
});
|
||||
}, Object.assign([], data));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user