Chore: Upgrade to Angular v14
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
@@ -26,7 +26,7 @@ import { IncentiveDataSource } from './incentive-datasource';
|
||||
export class IncentiveComponent implements OnInit {
|
||||
public incentiveObservable = new BehaviorSubject<Incentive[]>([]);
|
||||
dataSource: IncentiveDataSource = new IncentiveDataSource(this.incentiveObservable);
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
voucher: Voucher = new Voucher();
|
||||
account: Account = new Account();
|
||||
accBal: AccountBalance | null = null;
|
||||
@@ -36,7 +36,7 @@ export class IncentiveComponent implements OnInit {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
public auth: AuthService,
|
||||
@@ -47,7 +47,7 @@ export class IncentiveComponent implements OnInit {
|
||||
incentives: this.fb.array([]),
|
||||
});
|
||||
// Listen to Date Change
|
||||
(this.form.get('date') as FormControl).valueChanges
|
||||
(this.form.get('date') as UntypedFormControl).valueChanges
|
||||
.pipe(map((x) => moment(x).format('DD-MMM-YYYY')))
|
||||
.subscribe((x) => {
|
||||
if (x !== this.voucher.date && !this.voucher.id) {
|
||||
@@ -69,7 +69,7 @@ export class IncentiveComponent implements OnInit {
|
||||
|
||||
loadVoucher(voucher: Voucher) {
|
||||
this.voucher = voucher;
|
||||
(this.form.get('date') as FormControl).setValue(
|
||||
(this.form.get('date') as UntypedFormControl).setValue(
|
||||
moment(this.voucher.date, 'DD-MMM-YYYY').toDate(),
|
||||
);
|
||||
this.form.setControl(
|
||||
@@ -99,7 +99,7 @@ export class IncentiveComponent implements OnInit {
|
||||
less(row: Incentive, i: number) {
|
||||
if (row.points >= 1) {
|
||||
row.points -= 1;
|
||||
((this.form.get('incentives') as FormArray).get(`${i}`) as FormGroup).setValue({
|
||||
((this.form.get('incentives') as UntypedFormArray).get(`${i}`) as UntypedFormGroup).setValue({
|
||||
points: `${row.points}`,
|
||||
});
|
||||
}
|
||||
@@ -107,18 +107,18 @@ export class IncentiveComponent implements OnInit {
|
||||
|
||||
change(row: Incentive, i: number) {
|
||||
row.points = +(
|
||||
((this.form.get('incentives') as FormArray).get(`${i}`) as FormGroup).get(
|
||||
((this.form.get('incentives') as UntypedFormArray).get(`${i}`) as UntypedFormGroup).get(
|
||||
'points',
|
||||
) as FormControl
|
||||
) as UntypedFormControl
|
||||
).value;
|
||||
((this.form.get('incentives') as FormArray).get(`${i}`) as FormGroup).setValue({
|
||||
((this.form.get('incentives') as UntypedFormArray).get(`${i}`) as UntypedFormGroup).setValue({
|
||||
points: `${row.points}`,
|
||||
});
|
||||
}
|
||||
|
||||
more(row: Incentive, i: number) {
|
||||
row.points += 1;
|
||||
((this.form.get('incentives') as FormArray).get(`${i}`) as FormGroup).setValue({
|
||||
((this.form.get('incentives') as UntypedFormArray).get(`${i}`) as UntypedFormGroup).setValue({
|
||||
points: `${row.points}`,
|
||||
});
|
||||
}
|
||||
@@ -171,7 +171,7 @@ export class IncentiveComponent implements OnInit {
|
||||
getVoucher(): Voucher {
|
||||
const formModel = this.form.value;
|
||||
this.voucher.date = moment(formModel.date).format('DD-MMM-YYYY');
|
||||
const array = this.form.get('incentives') as FormArray;
|
||||
const array = this.form.get('incentives') as UntypedFormArray;
|
||||
this.voucher.incentives.forEach((item, index) => {
|
||||
item.points = array.controls[index].value.points;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user