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 { Employee } from '../employee';
|
||||
|
||||
|
||||
export class EmployeeListDataSource extends DataSource<Employee> {
|
||||
private filterValue: string;
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, private filter: Observable<string>, public data: Employee[]) {
|
||||
constructor(
|
||||
private paginator: MatPaginator,
|
||||
private sort: MatSort,
|
||||
private filter: Observable<string>,
|
||||
public data: Employee[],
|
||||
) {
|
||||
super();
|
||||
this.filter = filter.pipe(
|
||||
tap(x => this.filterValue = x)
|
||||
);
|
||||
this.filter = filter.pipe(tap((x) => (this.filterValue = x)));
|
||||
}
|
||||
|
||||
connect(): Observable<Employee[]> {
|
||||
@ -21,34 +23,41 @@ export class EmployeeListDataSource extends DataSource<Employee> {
|
||||
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: Employee[]) => 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: Employee[]) => (this.paginator.length = x.length)),
|
||||
)
|
||||
.pipe(
|
||||
map((x: any) => {
|
||||
return this.getPagedData(this.getSortedData(x));
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
|
||||
private getFilteredData(data: Employee[]): Employee[] {
|
||||
const filter = (this.filterValue === undefined) ? '' : this.filterValue;
|
||||
const filter = this.filterValue === undefined ? '' : this.filterValue;
|
||||
return filter.split(' ').reduce((p: Employee[], c: string) => {
|
||||
return p.filter(x => {
|
||||
const employeeString = (
|
||||
x.code + ' ' + x.name + ' ' + x.designation + ' ' + x.costCentre + (x.isActive ? ' active' : ' inactive')
|
||||
).toLowerCase();
|
||||
return employeeString.indexOf(c) !== -1;
|
||||
}
|
||||
);
|
||||
return p.filter((x) => {
|
||||
const employeeString = (
|
||||
x.code +
|
||||
' ' +
|
||||
x.name +
|
||||
' ' +
|
||||
x.designation +
|
||||
' ' +
|
||||
x.costCentre +
|
||||
(x.isActive ? ' active' : ' inactive')
|
||||
).toLowerCase();
|
||||
return employeeString.indexOf(c) !== -1;
|
||||
});
|
||||
}, Object.assign([], data));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user