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:
+3
-1
@@ -45,7 +45,9 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
if (this.nameElement) this.nameElement.nativeElement.focus();
|
||||
if (this.nameElement) {
|
||||
this.nameElement.nativeElement.focus();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { ProductGroupListResolver } from './product-group-list-resolver.service';
|
||||
|
||||
@@ -8,9 +8,7 @@ import { map } from 'rxjs/operators';
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
|
||||
/** 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 ProductGroupListDataSource extends DataSource<ProductGroup> {
|
||||
constructor(
|
||||
public data: ProductGroup[],
|
||||
@@ -26,11 +24,17 @@ export class ProductGroupListDataSource extends DataSource<ProductGroup> {
|
||||
| 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 ProductGroupListDataSource extends DataSource<ProductGroup> {
|
||||
disconnect() {}
|
||||
|
||||
private getPagedData(data: ProductGroup[]) {
|
||||
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: ProductGroup[]) {
|
||||
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 { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { ProductGroupResolver } from './product-group-resolver.service';
|
||||
|
||||
@@ -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 { ProductGroupService } from './product-group.service';
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ import { catchError } from 'rxjs/operators';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { ProductGroup } from '../core/product-group';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
const url = '/api/product-groups';
|
||||
const serviceName = 'ProductGroupService';
|
||||
|
||||
@@ -20,35 +17,29 @@ export class ProductGroupService {
|
||||
|
||||
get(id: string | null): Observable<ProductGroup> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
return <Observable<ProductGroup>>(
|
||||
this.http
|
||||
.get<ProductGroup>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
return this.http
|
||||
.get<ProductGroup>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id as Observable<ProductGroup>=${id}`)),
|
||||
) as Observable<ProductGroup>;
|
||||
}
|
||||
|
||||
list(): Observable<ProductGroup[]> {
|
||||
return <Observable<ProductGroup[]>>(
|
||||
this.http
|
||||
.get<ProductGroup[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
return this.http
|
||||
.get<ProductGroup[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<ProductGroup[]>;
|
||||
}
|
||||
|
||||
save(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
return <Observable<ProductGroup>>(
|
||||
this.http
|
||||
.post<ProductGroup>(`${url}`, productGroup, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
return this.http
|
||||
.post<ProductGroup>(`${url}`, productGroup)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<ProductGroup>;
|
||||
}
|
||||
|
||||
update(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
return <Observable<ProductGroup>>(
|
||||
this.http
|
||||
.put<ProductGroup>(`${url}/${productGroup.id}`, productGroup, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
return this.http
|
||||
.put<ProductGroup>(`${url}/${productGroup.id}`, productGroup)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<ProductGroup>;
|
||||
}
|
||||
|
||||
saveOrUpdate(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
@@ -59,10 +50,8 @@ export class ProductGroupService {
|
||||
}
|
||||
|
||||
delete(id: string): Observable<ProductGroup> {
|
||||
return <Observable<ProductGroup>>(
|
||||
this.http
|
||||
.delete<ProductGroup>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
|
||||
);
|
||||
return this.http
|
||||
.delete<ProductGroup>(`${url}/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<ProductGroup>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user