Upgraded to Angular 14
This commit is contained in:
2022-07-06 09:04:10 +05:30
parent f637f01954
commit 792ccf923f
46 changed files with 233 additions and 179 deletions

View File

@ -1,5 +1,10 @@
import { Component, ElementRef, Inject, ViewChild } from '@angular/core';
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
import {
UntypedFormArray,
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
} from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
@ -25,14 +30,14 @@ export class ReceivePaymentComponent {
reason = '';
displayReason: boolean;
displayTable: boolean;
form: FormGroup;
form: UntypedFormGroup;
dataSource: ReceivePaymentDatasource;
displayedColumns = ['name', 'amount'];
constructor(
public dialogRef: MatDialogRef<ReceivePaymentComponent>,
private fb: FormBuilder,
private fb: UntypedFormBuilder,
private ser: SettleOptionService,
@Inject(MAT_DIALOG_DATA) public data: { type: VoucherType; amount: number },
) {
@ -81,7 +86,7 @@ export class ReceivePaymentComponent {
}
listenToAmountChange() {
const array = this.form.get('amounts') as FormArray;
const array = this.form.get('amounts') as UntypedFormArray;
this.choices.forEach((z, i) =>
array.controls[i].valueChanges.pipe(distinctUntilChanged()).subscribe((x) => {
(this.choices.find((s) => s.name === x.name) as ReceivePaymentItem).amount =
@ -101,8 +106,8 @@ export class ReceivePaymentComponent {
}
maxAmount(row: ReceivePaymentItem, index: number) {
const array = this.form.get('amounts') as FormArray;
const ctrl = array.controls[index].get('amount') as FormControl;
const array = this.form.get('amounts') as UntypedFormArray;
const ctrl = array.controls[index].get('amount') as UntypedFormControl;
ctrl.setValue('' + (row.amount + this.balance));
}
}