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

View File

@ -27,7 +27,13 @@ export class PurchaseDialogComponent implements OnInit {
private math: MathService,
private productSer: ProductService,
) {
this.createForm();
this.form = this.fb.group({
product: '',
quantity: '',
price: '',
tax: '',
discount: '',
});
this.listenToProductAutocompleteChange();
}
@ -42,16 +48,6 @@ export class PurchaseDialogComponent implements OnInit {
this.product = this.data.inventory.product;
}
createForm() {
this.form = this.fb.group({
product: '',
quantity: '',
price: '',
tax: '',
discount: '',
});
}
listenToProductAutocompleteChange(): void {
const control = this.form.get('product');
this.products = control.valueChanges.pipe(

View File

@ -62,13 +62,28 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
private productSer: ProductService,
private accountSer: AccountService,
) {
this.createForm();
this.form = this.fb.group({
date: '',
account: '',
amount: { value: '', disabled: true },
addRow: this.fb.group({
product: '',
quantity: '',
price: '',
tax: '',
discount: '',
}),
narration: '',
});
this.accBal = null;
this.listenToAccountAutocompleteChange();
this.listenToProductAutocompleteChange();
}
ngOnInit() {
this.route.data.subscribe((data: { voucher: Voucher }) => {
this.route.data.subscribe((value) => {
const data = value as { voucher: Voucher };
this.loadVoucher(data.voucher);
});
this.hotkeys.add(
@ -225,23 +240,6 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
this.updateView();
}
createForm() {
this.form = this.fb.group({
date: '',
account: '',
amount: { value: '', disabled: true },
addRow: this.fb.group({
product: '',
quantity: '',
price: '',
tax: '',
discount: '',
}),
narration: '',
});
this.accBal = null;
}
canSave() {
if (!this.voucher.id) {
return true;