Chore: Upgrade to Angular v14
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@@ -30,7 +30,7 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
this.employeeAttendanceObservable,
|
||||
);
|
||||
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
|
||||
info: EmployeeAttendance = new EmployeeAttendance();
|
||||
attendanceTypes: AttendanceType[] = [];
|
||||
@@ -42,7 +42,7 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private auth: AuthService,
|
||||
@@ -56,7 +56,7 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
attendances: this.fb.array([]),
|
||||
});
|
||||
// Listen to Employee Value Changes
|
||||
this.employees = (this.form.get('employee') as FormControl).valueChanges.pipe(
|
||||
this.employees = (this.form.get('employee') as UntypedFormControl).valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
@@ -71,13 +71,13 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
|
||||
this.info = data.info;
|
||||
this.attendanceTypes = data.attendanceTypes;
|
||||
(this.form.get('startDate') as FormControl).setValue(
|
||||
(this.form.get('startDate') as UntypedFormControl).setValue(
|
||||
moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
);
|
||||
(this.form.get('finishDate') as FormControl).setValue(
|
||||
(this.form.get('finishDate') as UntypedFormControl).setValue(
|
||||
moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
);
|
||||
(this.form.get('employee') as FormControl).setValue(this.info.employee);
|
||||
(this.form.get('employee') as UntypedFormControl).setValue(this.info.employee);
|
||||
this.form.setControl(
|
||||
'attendances',
|
||||
this.fb.array(
|
||||
@@ -110,7 +110,7 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
getClass(index: number) {
|
||||
const array = this.form.get('attendances') as FormArray;
|
||||
const array = this.form.get('attendances') as UntypedFormArray;
|
||||
const id = array.controls[index].value.attendanceType;
|
||||
const { name } = this.attendanceTypes.filter((x) => x.id === id)[0];
|
||||
return name.toLowerCase().replace(/(\s+\+\s+)|(\s+)/g, '-');
|
||||
@@ -143,14 +143,14 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
const formValue = this.form.value;
|
||||
this.info.startDate = moment(formValue.startDate).format('DD-MMM-YYYY');
|
||||
this.info.finishDate = moment(formValue.finishDate).format('DD-MMM-YYYY');
|
||||
const array = this.form.get('attendances') as FormArray;
|
||||
const array = this.form.get('attendances') as UntypedFormArray;
|
||||
this.info.body.forEach((item, index) => {
|
||||
item.attendanceType.id = array.controls[index].value.attendanceType;
|
||||
});
|
||||
return this.info;
|
||||
}
|
||||
|
||||
get attendancesArray(): FormArray {
|
||||
return this.form.get('attendances') as FormArray;
|
||||
get attendancesArray(): UntypedFormArray {
|
||||
return this.form.get('attendances') as UntypedFormArray;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user