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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user