Prettied, Linted and updated angular.json according to the latest schematic of Angular CLI.
Now all that is needed is to make it ready for strict compiling. Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier Bumped to v8.0.0
This commit is contained in:
@ -1,10 +1,16 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { Employee } from '../employee';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a, b, isAsc) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
|
||||
export class EmployeeListDataSource extends DataSource<Employee> {
|
||||
private filterValue: string;
|
||||
|
||||
@ -15,7 +21,11 @@ export class EmployeeListDataSource extends DataSource<Employee> {
|
||||
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[]> {
|
||||
@ -28,37 +38,28 @@ export class EmployeeListDataSource extends DataSource<Employee> {
|
||||
|
||||
return merge(...dataMutations)
|
||||
.pipe(
|
||||
map((x: any) => {
|
||||
return this.getFilteredData([...this.data]);
|
||||
map(() => this.getFilteredData([...this.data])),
|
||||
tap((x: Employee[]) => {
|
||||
this.paginator.length = x.length;
|
||||
}),
|
||||
tap((x: Employee[]) => (this.paginator.length = x.length)),
|
||||
)
|
||||
.pipe(
|
||||
map((x: any) => {
|
||||
return this.getPagedData(this.getSortedData(x));
|
||||
}),
|
||||
);
|
||||
.pipe(map((x: any) => this.getPagedData(this.getSortedData(x))));
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
|
||||
private getFilteredData(data: Employee[]): Employee[] {
|
||||
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;
|
||||
});
|
||||
}, Object.assign([], data));
|
||||
return filter.split(' ').reduce(
|
||||
(p: Employee[], c: string) =>
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
private getPagedData(data: Employee[]) {
|
||||
@ -96,8 +97,3 @@ export class EmployeeListDataSource extends DataSource<Employee> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a, b, isAsc) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { EmployeeListDataSource } from './employee-list-datasource';
|
||||
import { Employee } from '../employee';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { Observable } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, startWith } from 'rxjs/operators';
|
||||
|
||||
import { ToCsvService } from '../../shared/to-csv.service';
|
||||
import { Employee } from '../employee';
|
||||
|
||||
import { EmployeeListDataSource } from './employee-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-employee-list',
|
||||
|
||||
Reference in New Issue
Block a user