Chore: Upgrade to Angular v14
This commit is contained in:
+8
-8
@@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, 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';
|
||||
@@ -31,7 +31,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('productElement', { static: true }) productElement?: ElementRef;
|
||||
public itemsObservable = new BehaviorSubject<RateContractItem[]>([]);
|
||||
dataSource: RateContractDetailDatasource = new RateContractDetailDatasource(this.itemsObservable);
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
item: RateContract = new RateContract();
|
||||
|
||||
product: Product | null = null;
|
||||
@@ -44,7 +44,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private dialog: MatDialog,
|
||||
private math: MathService,
|
||||
@@ -63,7 +63,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
}),
|
||||
narration: '',
|
||||
});
|
||||
this.accounts = (this.form.get('account') as FormControl).valueChanges.pipe(
|
||||
this.accounts = (this.form.get('account') as UntypedFormControl).valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
@@ -72,7 +72,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
);
|
||||
// Listen to Product Autocomplete Change
|
||||
this.products = (
|
||||
(this.form.get('addRow') as FormControl).get('product') as FormControl
|
||||
(this.form.get('addRow') as UntypedFormControl).get('product') as UntypedFormControl
|
||||
).valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
@@ -115,7 +115,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
addRow() {
|
||||
const formValue = (this.form.get('addRow') as FormControl).value;
|
||||
const formValue = (this.form.get('addRow') as UntypedFormControl).value;
|
||||
const price = this.math.parseAmount(formValue.price, 2);
|
||||
if (this.product === null || price <= 0) {
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
resetAddRow() {
|
||||
(this.form.get('addRow') as FormControl).reset({
|
||||
(this.form.get('addRow') as UntypedFormControl).reset({
|
||||
product: null,
|
||||
price: '',
|
||||
});
|
||||
@@ -157,7 +157,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
||||
(this.form.get('account') as FormControl).setValue(event.option.value);
|
||||
(this.form.get('account') as UntypedFormControl).setValue(event.option.value);
|
||||
}
|
||||
|
||||
productSelected(event: MatAutocompleteSelectedEvent): void {
|
||||
|
||||
Reference in New Issue
Block a user