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,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(
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user