Moving to strict.

Create form has now moved to constructor and route data subscribe is type safe.
This commit is contained in:
2020-11-23 09:18:02 +05:30
parent 30b1a3ef7d
commit 39e3cc51bb
52 changed files with 348 additions and 448 deletions
@@ -30,10 +30,6 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
private toaster: ToasterService,
private ser: AccountService,
) {
this.createForm();
}
createForm() {
this.form = this.fb.group({
code: { value: '', disabled: true },
name: '',
@@ -45,13 +41,17 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.route.data.subscribe(
(data: { item: Account; accountTypes: AccountType[]; costCentres: CostCentre[] }) => {
this.accountTypes = data.accountTypes;
this.costCentres = data.costCentres;
this.showItem(data.item);
},
);
this.route.data.subscribe((value) => {
const data = value as {
item: Account;
accountTypes: AccountType[];
costCentres: CostCentre[];
};
this.accountTypes = data.accountTypes;
this.costCentres = data.costCentres;
this.showItem(data.item);
});
}
showItem(item: Account) {
@@ -28,14 +28,10 @@ export class AccountListComponent implements OnInit, AfterViewInit {
displayedColumns = ['name', 'type', 'isActive', 'isReconcilable', 'costCentre'];
constructor(private route: ActivatedRoute, private fb: FormBuilder) {
this.createForm();
this.filter = this.listenToFilterChange();
}
createForm() {
this.form = this.fb.group({
filter: '',
});
this.filter = this.listenToFilterChange();
}
listenToFilterChange() {
@@ -45,7 +41,9 @@ export class AccountListComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.route.data.subscribe((data: { list: Account[] }) => {
this.route.data.subscribe((value) => {
const data = value as { list: Account[] };
this.list = data.list;
});
this.dataSource = new AccountListDataSource(this.paginator, this.sort, this.filter, this.list);