Fix: Login deleting old clients was conflicting with login history
Chore: Moved to angular linting using the recommended plugins / settings
This commit is contained in:
@ -8,9 +8,7 @@ import { map } from 'rxjs/operators';
|
||||
import { PurchasesItem } from './purchases-item';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a: string | number, b: string | number, isAsc: boolean) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
const compare = (a: string | number, b: string | number, isAsc: boolean) => (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
export class PurchasesDataSource extends DataSource<PurchasesItem> {
|
||||
constructor(
|
||||
public data: PurchasesItem[],
|
||||
@ -26,11 +24,17 @@ export class PurchasesDataSource extends DataSource<PurchasesItem> {
|
||||
| EventEmitter<PageEvent>
|
||||
| EventEmitter<Sort>
|
||||
)[] = [observableOf(this.data)];
|
||||
if (this.paginator) dataMutations.push((this.paginator as MatPaginator).page);
|
||||
if (this.sort) dataMutations.push((this.sort as MatSort).sortChange);
|
||||
if (this.paginator) {
|
||||
dataMutations.push((this.paginator as MatPaginator).page);
|
||||
}
|
||||
if (this.sort) {
|
||||
dataMutations.push((this.sort as MatSort).sortChange);
|
||||
}
|
||||
|
||||
// Set the paginators length
|
||||
if (this.paginator) this.paginator.length = this.data.length;
|
||||
if (this.paginator) {
|
||||
this.paginator.length = this.data.length;
|
||||
}
|
||||
|
||||
return merge(...dataMutations).pipe(
|
||||
map(() => this.getPagedData(this.getSortedData([...this.data]))),
|
||||
@ -40,13 +44,17 @@ export class PurchasesDataSource extends DataSource<PurchasesItem> {
|
||||
disconnect() {}
|
||||
|
||||
private getPagedData(data: PurchasesItem[]) {
|
||||
if (this.paginator === undefined) return data;
|
||||
if (this.paginator === undefined) {
|
||||
return data;
|
||||
}
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
return data.splice(startIndex, this.paginator.pageSize);
|
||||
}
|
||||
|
||||
private getSortedData(data: PurchasesItem[]) {
|
||||
if (this.sort === undefined) return data;
|
||||
if (this.sort === undefined) {
|
||||
return data;
|
||||
}
|
||||
if (!this.sort.active || this.sort.direction === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PurchasesResolver } from './purchases-resolver.service';
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { PurchasesComponent } from './purchases.component';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PurchasesService } from './purchases.service';
|
||||
|
||||
|
||||
@ -19,10 +19,8 @@ export class PurchasesService {
|
||||
list(startDate: string | null, finishDate: string | null): Observable<Purchases> {
|
||||
const startDateWithSlash = startDate ? `/${startDate}` : '';
|
||||
const finishDateWithSlash = finishDate ? `/${finishDate}` : '';
|
||||
return <Observable<Purchases>>(
|
||||
this.http
|
||||
.get<Purchases>(`${url}${startDateWithSlash}${finishDateWithSlash}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
return this.http
|
||||
.get<Purchases>(`${url}${startDateWithSlash}${finishDateWithSlash}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Purchases>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user