Chore: Upgrade to Angular v14

This commit is contained in:
2022-07-11 20:12:38 +05:30
parent a4c3ae1035
commit b1c003a935
54 changed files with 355 additions and 325 deletions
+10 -10
View File
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, ElementRef, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
@@ -37,7 +37,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('dateElement', { static: true }) dateElement?: ElementRef;
public journalObservable = new BehaviorSubject<Journal[]>([]);
dataSource: PaymentDataSource = new PaymentDataSource(this.journalObservable);
form: FormGroup;
form: UntypedFormGroup;
paymentAccounts: Account[] = [];
paymentJournal: Journal = new Journal();
voucher: Voucher = new Voucher();
@@ -51,7 +51,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private fb: UntypedFormBuilder,
private dialog: MatDialog,
private hotkeys: HotkeysService,
private toaster: ToasterService,
@@ -75,7 +75,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
this.accBal = null;
// Listen to Account Autocomplete Change
this.accounts = (
(this.form.get('addRow') as FormControl).get('account') as FormControl
(this.form.get('addRow') as UntypedFormControl).get('account') as UntypedFormControl
).valueChanges.pipe(
startWith(null),
map((x) => (x !== null && x.length >= 1 ? x : null)),
@@ -84,7 +84,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
switchMap((x) => (x === null ? observableOf([]) : this.accountSer.autocomplete(x))),
);
// Listen to Payment Account Change
(this.form.get('paymentAccount') as FormControl).valueChanges.subscribe((x) =>
(this.form.get('paymentAccount') as UntypedFormControl).valueChanges.subscribe((x) =>
this.router.navigate([], {
relativeTo: this.route,
queryParams: { a: x },
@@ -174,7 +174,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
}
addRow() {
const amount = this.math.parseAmount((this.form.get('addRow') as FormControl).value.amount, 2);
const amount = this.math.parseAmount((this.form.get('addRow') as UntypedFormControl).value.amount, 2);
const debit = 1;
if (this.account === null || amount <= 0) {
return;
@@ -203,7 +203,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
}
resetAddRow() {
(this.form.get('addRow') as FormControl).reset({
(this.form.get('addRow') as UntypedFormControl).reset({
account: null,
amount: null,
});
@@ -223,7 +223,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
Math.abs(journals.map((x) => x.amount).reduce((p, c) => p + c, 0)),
2,
);
(this.form.get('paymentAmount') as FormControl).setValue(this.paymentJournal.amount);
(this.form.get('paymentAmount') as UntypedFormControl).setValue(this.paymentJournal.amount);
}
editRow(row: Journal) {
@@ -231,7 +231,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
width: '750px',
data: {
journal: { ...row },
date: moment((this.form.get('date') as FormControl).value).format('DD-MMM-YYYY'),
date: moment((this.form.get('date') as UntypedFormControl).value).format('DD-MMM-YYYY'),
},
});
@@ -338,7 +338,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
accountSelected(event: MatAutocompleteSelectedEvent): void {
const account = event.option.value;
this.account = account;
const date = moment((this.form.get('date') as FormControl).value).format('DD-MMM-YYYY');
const date = moment((this.form.get('date') as UntypedFormControl).value).format('DD-MMM-YYYY');
this.accountSer.balance(account.id as string, date).subscribe((v) => {
this.accBal = v;
});