Moving to strict.
Create form has now moved to constructor and route data subscribe is type safe.
This commit is contained in:
@ -27,7 +27,11 @@ export class ReceiptDialogComponent implements OnInit {
|
||||
private math: MathService,
|
||||
private accountSer: AccountService,
|
||||
) {
|
||||
this.createForm();
|
||||
this.form = this.fb.group({
|
||||
account: '',
|
||||
amount: '',
|
||||
});
|
||||
this.accBal = null;
|
||||
this.setupAccountAutocomplete();
|
||||
}
|
||||
|
||||
@ -39,14 +43,6 @@ export class ReceiptDialogComponent implements OnInit {
|
||||
this.account = this.data.journal.account;
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
account: '',
|
||||
amount: '',
|
||||
});
|
||||
this.accBal = null;
|
||||
}
|
||||
|
||||
setupAccountAutocomplete(): void {
|
||||
const control = this.form.get('account');
|
||||
this.accounts = control.valueChanges.pipe(
|
||||
|
||||
@ -60,13 +60,25 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
private accountSer: AccountService,
|
||||
) {
|
||||
this.account = null;
|
||||
this.createForm();
|
||||
this.form = this.fb.group({
|
||||
date: '',
|
||||
receiptAccount: '',
|
||||
receiptAmount: { value: '', disabled: true },
|
||||
addRow: this.fb.group({
|
||||
account: '',
|
||||
amount: '',
|
||||
}),
|
||||
narration: '',
|
||||
});
|
||||
this.accBal = null;
|
||||
this.listenToAccountAutocompleteChange();
|
||||
this.listenToReceiptAccountChange();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { voucher: Voucher; receiptAccounts: Account[] }) => {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { voucher: Voucher; receiptAccounts: Account[] };
|
||||
|
||||
this.receiptAccounts = data.receiptAccounts;
|
||||
this.loadVoucher(data.voucher);
|
||||
});
|
||||
@ -221,20 +233,6 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
date: '',
|
||||
receiptAccount: '',
|
||||
receiptAmount: { value: '', disabled: true },
|
||||
addRow: this.fb.group({
|
||||
account: '',
|
||||
amount: '',
|
||||
}),
|
||||
narration: '',
|
||||
});
|
||||
this.accBal = null;
|
||||
}
|
||||
|
||||
canSave() {
|
||||
if (!this.voucher.id) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user