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:
@@ -2,28 +2,48 @@
|
||||
<mat-card fxFlex>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Account</mat-card-title>
|
||||
<mat-icon matSuffix (click)="item.isStarred = !item.isStarred" class="pointer" [class.gold]="item.isStarred">
|
||||
<mat-icon
|
||||
matSuffix
|
||||
(click)="item.isStarred = !item.isStarred"
|
||||
class="pointer"
|
||||
[class.gold]="item.isStarred"
|
||||
>
|
||||
{{ item.isStarred ? 'star' : 'star_border' }}
|
||||
</mat-icon>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Code</mat-label>
|
||||
<input matInput placeholder="Code" formControlName="code">
|
||||
<input matInput placeholder="Code" formControlName="code" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name">
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Account Type</mat-label>
|
||||
<mat-select placeholder="Account Type" formControlName="type">
|
||||
@@ -33,13 +53,23 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
<mat-checkbox formControlName="isReconcilable">Is Reconcilable?</mat-checkbox>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Cost Centre</mat-label>
|
||||
<mat-select placeholder="Cost Centre" formControlName="costCentre">
|
||||
@@ -53,7 +83,9 @@
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" (click)="save()">Save</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
|
||||
Delete
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {AccountDetailComponent} from './account-detail.component';
|
||||
import { AccountDetailComponent } from './account-detail.component';
|
||||
|
||||
describe('AccountDetailComponent', () => {
|
||||
let component: AccountDetailComponent;
|
||||
@@ -8,9 +8,8 @@ describe('AccountDetailComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AccountDetailComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [AccountDetailComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {AccountService} from '../../core/account.service';
|
||||
import {Account} from '../../core/account';
|
||||
import {AccountType} from '../../core/account-type';
|
||||
import {CostCentre} from '../../core/cost-centre';
|
||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AccountService } from '../../core/account.service';
|
||||
import { Account } from '../../core/account';
|
||||
import { AccountType } from '../../core/account-type';
|
||||
import { CostCentre } from '../../core/cost-centre';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-detail',
|
||||
templateUrl: './account-detail.component.html',
|
||||
styleUrls: ['./account-detail.component.css']
|
||||
styleUrls: ['./account-detail.component.css'],
|
||||
})
|
||||
export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
@@ -27,29 +27,30 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: AccountService
|
||||
private ser: AccountService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
code: {value: '', disabled: true},
|
||||
code: { value: '', disabled: true },
|
||||
name: '',
|
||||
type: '',
|
||||
isActive: '',
|
||||
isReconcilable: '',
|
||||
costCentre: ''
|
||||
costCentre: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Account, accountTypes: AccountType[], costCentres: CostCentre[] }) => {
|
||||
this.route.data.subscribe(
|
||||
(data: { item: Account; accountTypes: AccountType[]; costCentres: CostCentre[] }) => {
|
||||
this.accountTypes = data.accountTypes;
|
||||
this.costCentres = data.costCentres;
|
||||
this.showItem(data.item);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
showItem(item: Account) {
|
||||
@@ -60,7 +61,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
type: this.item.type,
|
||||
isActive: this.item.isActive,
|
||||
isReconcilable: this.item.isReconcilable,
|
||||
costCentre: this.item.costCentre.id
|
||||
costCentre: this.item.costCentre.id,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,35 +72,33 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/accounts');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/accounts');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/accounts');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
}
|
||||
);
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/accounts');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Account?', content: 'Are you sure? This cannot be undone.'}
|
||||
data: { title: 'Delete Account?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {AccountListResolverService} from './account-list-resolver.service';
|
||||
import { AccountListResolverService } from './account-list-resolver.service';
|
||||
|
||||
describe('AccountListResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AccountListResolverService]
|
||||
providers: [AccountListResolverService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([AccountListResolverService], (service: AccountListResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
it('should be created', inject(
|
||||
[AccountListResolverService],
|
||||
(service: AccountListResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Account} from '../core/account';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {AccountService} from '../core/account.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Account } from '../core/account';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { AccountService } from '../core/account.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AccountListResolver implements Resolve<Account[]> {
|
||||
|
||||
constructor(private ser: AccountService) {
|
||||
}
|
||||
constructor(private ser: AccountService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Account[]> {
|
||||
return this.ser.list();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,23 +8,33 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<input type="text" matInput #filterElement placeholder="Filter" formControlName="filter" autocomplete="off">
|
||||
<input
|
||||
type="text"
|
||||
matInput
|
||||
#filterElement
|
||||
placeholder="Filter"
|
||||
formControlName="filter"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<a [routerLink]="['/accounts', row.id]">
|
||||
<mat-icon matSuffix *ngIf="row.isStarred" class="gold">star
|
||||
</mat-icon>
|
||||
{{row.name}}
|
||||
<mat-icon matSuffix *ngIf="row.isStarred" class="gold">star </mat-icon>
|
||||
{{ row.name }}
|
||||
</a>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
@@ -32,36 +42,38 @@
|
||||
<!-- Type Column -->
|
||||
<ng-container matColumnDef="type">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.type}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.type }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Active? Column -->
|
||||
<ng-container matColumnDef="isActive">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Is Active?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.isActive}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.isActive }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Reconcilable? Column -->
|
||||
<ng-container matColumnDef="isReconcilable">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Is Reconcilable?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.isReconcilable}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.isReconcilable }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Cost Centre Column -->
|
||||
<ng-container matColumnDef="costCentre">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Cost Centre</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.costCentre}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.costCentre }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
|
||||
<mat-paginator #paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250]">
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250]"
|
||||
>
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {AccountListComponent} from './account-list.component';
|
||||
import { AccountListComponent } from './account-list.component';
|
||||
|
||||
describe('AccountListComponent', () => {
|
||||
let component: AccountListComponent;
|
||||
@@ -8,9 +8,8 @@ describe('AccountListComponent', () => {
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AccountListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [AccountListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AccountListComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {AccountListDataSource} from './account-list-datasource';
|
||||
import {Account} from '../../core/account';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Observable} from 'rxjs';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
||||
import { AccountListDataSource } from './account-list-datasource';
|
||||
import { Account } from '../../core/account';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { debounceTime, distinctUntilChanged, startWith } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-list',
|
||||
templateUrl: './account-list.component.html',
|
||||
styleUrls: ['./account-list.component.css']
|
||||
styleUrls: ['./account-list.component.css'],
|
||||
})
|
||||
export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('filterElement', { static: true }) filterElement: ElementRef;
|
||||
@@ -32,24 +32,20 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
filter: ''
|
||||
filter: '',
|
||||
});
|
||||
}
|
||||
|
||||
listenToFilterChange() {
|
||||
return this.form.get('filter').valueChanges
|
||||
.pipe(
|
||||
startWith(''),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
return this.form
|
||||
.get('filter')
|
||||
.valueChanges.pipe(startWith(''), debounceTime(150), distinctUntilChanged());
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Account[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
this.route.data.subscribe((data: { list: Account[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
this.dataSource = new AccountListDataSource(this.paginator, this.sort, this.filter, this.list);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {AccountResolverService} from './account-resolver.service';
|
||||
import { AccountResolverService } from './account-resolver.service';
|
||||
|
||||
describe('AccountResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AccountDetailResolverService]
|
||||
providers: [AccountDetailResolverService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([AccountDetailResolverService], (service: AccountDetailResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
it('should be created', inject(
|
||||
[AccountDetailResolverService],
|
||||
(service: AccountDetailResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {AccountService} from '../core/account.service';
|
||||
import {Account} from '../core/account';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { AccountService } from '../core/account.service';
|
||||
import { Account } from '../core/account';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AccountResolver implements Resolve<Account> {
|
||||
|
||||
constructor(private ser: AccountService, private router: Router) {
|
||||
}
|
||||
constructor(private ser: AccountService, private router: Router) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Account> {
|
||||
const id = route.paramMap.get('id');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AccountRoutingModule} from './account-routing.module';
|
||||
import { AccountRoutingModule } from './account-routing.module';
|
||||
|
||||
describe('AccountRoutingModule', () => {
|
||||
let accountRoutingModule: AccountRoutingModule;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import {AccountListResolver} from './account-list-resolver.service';
|
||||
import {AccountResolver} from './account-resolver.service';
|
||||
import {AccountTypeResolver} from './account-type-resolver.service';
|
||||
import {AccountDetailComponent} from './account-detail/account-detail.component';
|
||||
import {AccountListComponent} from './account-list/account-list.component';
|
||||
import { AccountListResolver } from './account-list-resolver.service';
|
||||
import { AccountResolver } from './account-resolver.service';
|
||||
import { AccountTypeResolver } from './account-type-resolver.service';
|
||||
import { AccountDetailComponent } from './account-detail/account-detail.component';
|
||||
import { AccountListComponent } from './account-list/account-list.component';
|
||||
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {CostCentreListResolver} from '../cost-centre/cost-centre-list-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { CostCentreListResolver } from '../cost-centre/cost-centre-list-resolver.service';
|
||||
|
||||
const accountRoutes: Routes = [
|
||||
{
|
||||
@@ -17,53 +17,43 @@ const accountRoutes: Routes = [
|
||||
component: AccountListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Accounts'
|
||||
permission: 'Accounts',
|
||||
},
|
||||
resolve: {
|
||||
list: AccountListResolver
|
||||
}
|
||||
list: AccountListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: AccountDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Accounts'
|
||||
permission: 'Accounts',
|
||||
},
|
||||
resolve: {
|
||||
item: AccountResolver,
|
||||
accountTypes: AccountTypeResolver,
|
||||
costCentres: CostCentreListResolver
|
||||
}
|
||||
costCentres: CostCentreListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: AccountDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Accounts'
|
||||
permission: 'Accounts',
|
||||
},
|
||||
resolve: {
|
||||
item: AccountResolver,
|
||||
accountTypes: AccountTypeResolver,
|
||||
costCentres: CostCentreListResolver
|
||||
}
|
||||
}
|
||||
costCentres: CostCentreListResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(accountRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
AccountListResolver,
|
||||
AccountResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(accountRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [AccountListResolver, AccountResolver],
|
||||
})
|
||||
export class AccountRoutingModule {
|
||||
}
|
||||
export class AccountRoutingModule {}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {AccountTypeResolverService} from './account-type-resolver.service';
|
||||
import { AccountTypeResolverService } from './account-type-resolver.service';
|
||||
|
||||
describe('AccountTypeResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AccountTypeResolverService]
|
||||
providers: [AccountTypeResolverService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([AccountTypeResolverService], (service: AccountTypeResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
it('should be created', inject(
|
||||
[AccountTypeResolverService],
|
||||
(service: AccountTypeResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {AccountType} from '../core/account-type';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {AccountTypeService} from './account-type.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { AccountType } from '../core/account-type';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { AccountTypeService } from './account-type.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AccountTypeResolver implements Resolve<AccountType[]> {
|
||||
|
||||
constructor(private ser: AccountTypeService) {
|
||||
}
|
||||
constructor(private ser: AccountTypeService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<AccountType[]> {
|
||||
return this.ser.list();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {AccountTypeService} from './account-type.service';
|
||||
import { AccountTypeService } from './account-type.service';
|
||||
|
||||
describe('AccountTypeService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AccountTypeService]
|
||||
providers: [AccountTypeService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {AccountType} from '../core/account-type';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { AccountType } from '../core/account-type';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const url = '/api/account-types';
|
||||
const serviceName = 'AccountTypeService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AccountTypeService {
|
||||
|
||||
constructor(
|
||||
private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(): Observable<AccountType[]> {
|
||||
return <Observable<AccountType[]>>this.http.get<AccountType[]>(url)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
return <Observable<AccountType[]>>(
|
||||
this.http.get<AccountType[]>(url).pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AccountModule} from './account.module';
|
||||
import { AccountModule } from './account.module';
|
||||
|
||||
describe('AccountModule', () => {
|
||||
let accountModule: AccountModule;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import {AccountListComponent} from './account-list/account-list.component';
|
||||
import {AccountDetailComponent} from './account-detail/account-detail.component';
|
||||
import {AccountRoutingModule} from './account-routing.module';
|
||||
import { AccountListComponent } from './account-list/account-list.component';
|
||||
import { AccountDetailComponent } from './account-detail/account-detail.component';
|
||||
import { AccountRoutingModule } from './account-routing.module';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
@@ -15,9 +15,9 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import {CdkTableModule} from '@angular/cdk/table';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -36,12 +36,8 @@ import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
MatSelectModule,
|
||||
MatCheckboxModule,
|
||||
ReactiveFormsModule,
|
||||
AccountRoutingModule
|
||||
AccountRoutingModule,
|
||||
],
|
||||
declarations: [
|
||||
AccountListComponent,
|
||||
AccountDetailComponent
|
||||
]
|
||||
declarations: [AccountListComponent, AccountDetailComponent],
|
||||
})
|
||||
export class AccountModule {
|
||||
}
|
||||
export class AccountModule {}
|
||||
|
||||
Reference in New Issue
Block a user