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,13 +1,14 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AccountService } from '../../core/account.service';
|
||||
|
||||
import { Account } from '../../core/account';
|
||||
import { AccountType } from '../../core/account-type';
|
||||
import { AccountService } from '../../core/account.service';
|
||||
import { CostCentre } from '../../core/cost-centre';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-detail',
|
||||
@@ -73,7 +74,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
(result) => {
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/accounts');
|
||||
},
|
||||
@@ -85,7 +86,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
(result) => {
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/accounts');
|
||||
},
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Account } from '../core/account';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Account } from '../core/account';
|
||||
import { AccountService } from '../core/account.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -10,7 +11,7 @@ import { AccountService } from '../core/account.service';
|
||||
export class AccountListResolver implements Resolve<Account[]> {
|
||||
constructor(private ser: AccountService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Account[]> {
|
||||
resolve(): Observable<Account[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 { Account } from '../../core/account';
|
||||
|
||||
/** 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 AccountListDataSource extends DataSource<Account> {
|
||||
private filterValue: string;
|
||||
|
||||
@@ -15,7 +21,11 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
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[]> {
|
||||
@@ -28,35 +38,28 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
|
||||
return merge(...dataMutations)
|
||||
.pipe(
|
||||
map((x: any) => {
|
||||
return this.getFilteredData([...this.data]);
|
||||
map(() => this.getFilteredData([...this.data])),
|
||||
tap((x: Account[]) => {
|
||||
this.paginator.length = x.length;
|
||||
}),
|
||||
tap((x: Account[]) => (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: Account[]): Account[] {
|
||||
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;
|
||||
});
|
||||
}, Object.assign([], data));
|
||||
return filter.split(' ').reduce(
|
||||
(p: Account[], c: string) =>
|
||||
p.filter((x) => {
|
||||
const accountString = `${x.name} ${x.type} ${x.costCentre}${
|
||||
x.isActive ? ' active' : ' inactive'
|
||||
}`.toLowerCase();
|
||||
return accountString.indexOf(c) !== -1;
|
||||
}),
|
||||
Object.assign([], data),
|
||||
);
|
||||
}
|
||||
|
||||
private getPagedData(data: Account[]) {
|
||||
@@ -90,8 +93,3 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** 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 { 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 { Account } from '../../core/account';
|
||||
|
||||
import { AccountListDataSource } from './account-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-list',
|
||||
templateUrl: './account-list.component.html',
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
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 { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Account } from '../core/account';
|
||||
import { AccountService } from '../core/account.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AccountResolver implements Resolve<Account> {
|
||||
constructor(private ser: AccountService, private router: Router) {}
|
||||
constructor(private ser: AccountService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Account> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Account> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
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 { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { CostCentreListResolver } from '../cost-centre/cost-centre-list-resolver.service';
|
||||
|
||||
import { AccountDetailComponent } from './account-detail/account-detail.component';
|
||||
import { AccountListResolver } from './account-list-resolver.service';
|
||||
import { AccountListComponent } from './account-list/account-list.component';
|
||||
import { AccountResolver } from './account-resolver.service';
|
||||
import { AccountTypeResolver } from './account-type-resolver.service';
|
||||
|
||||
const accountRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { AccountType } from '../core/account-type';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { AccountType } from '../core/account-type';
|
||||
|
||||
import { AccountTypeService } from './account-type.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -10,7 +12,7 @@ import { AccountTypeService } from './account-type.service';
|
||||
export class AccountTypeResolver implements Resolve<AccountType[]> {
|
||||
constructor(private ser: AccountTypeService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<AccountType[]> {
|
||||
resolve(): Observable<AccountType[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
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 { AccountType } from '../core/account-type';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const url = '/api/account-types';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
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 { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
@@ -15,9 +14,10 @@ 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 { AccountDetailComponent } from './account-detail/account-detail.component';
|
||||
import { AccountListComponent } from './account-list/account-list.component';
|
||||
import { AccountRoutingModule } from './account-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
||||
Reference in New Issue
Block a user