Strict done!!

This commit is contained in:
2020-11-23 16:42:54 +05:30
parent af343cb7f9
commit afe746ecdc
142 changed files with 1258 additions and 907 deletions
@@ -18,9 +18,9 @@ import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dial
export class AccountDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: FormGroup;
accountTypes: AccountType[];
costCentres: CostCentre[];
item: Account;
accountTypes: AccountType[] = [];
costCentres: CostCentre[] = [];
item: Account = new Account();
constructor(
private route: ActivatedRoute,
@@ -68,7 +68,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
this.nameElement.nativeElement.focus();
if (this.nameElement) this.nameElement.nativeElement.focus();
}, 0);
}
@@ -85,7 +85,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
}
delete() {
this.ser.delete(this.item.id).subscribe(
this.ser.delete(this.item.id as string).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/accounts');
@@ -12,7 +12,7 @@ function compare(a: string | number | boolean, b: string | number | boolean, isA
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
}
export class AccountListDataSource extends DataSource<Account> {
private filterValue: string = "";
private filterValue = '';
constructor(
public data: Account[],
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { ActivatedRoute } from '@angular/router';
@@ -22,7 +22,7 @@ export class AccountListComponent implements OnInit, AfterViewInit {
dataSource: AccountListDataSource;
filter: Observable<string>;
form: FormGroup;
list: Account[];
list: Account[] = [];
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'type', 'isActive', 'isReconcilable', 'costCentre'];
@@ -31,13 +31,13 @@ export class AccountListComponent implements OnInit, AfterViewInit {
this.form = this.fb.group({
filter: '',
});
this.filter = this.listenToFilterChange();
}
listenToFilterChange() {
return this.form
.get('filter')
.valueChanges.pipe(startWith(''), debounceTime(150), distinctUntilChanged());
// Listen to Filter Change
this.filter = (this.form.get('filter') as FormControl).valueChanges.pipe(
startWith(''),
debounceTime(150),
distinctUntilChanged(),
);
this.dataSource = new AccountListDataSource(this.list, this.filter);
}
ngOnInit() {
@@ -46,12 +46,12 @@ export class AccountListComponent implements OnInit, AfterViewInit {
this.list = data.list;
});
this.dataSource = new AccountListDataSource(this.paginator, this.sort, this.filter, this.list);
this.dataSource = new AccountListDataSource(this.list, this.filter, this.paginator, this.sort);
}
ngAfterViewInit() {
setTimeout(() => {
this.filterElement.nativeElement.focus();
if (this.filterElement) this.filterElement.nativeElement.focus();
}, 0);
}
}