Strict done!!

This commit is contained in:
2020-11-23 16:42:54 +05:30
parent af343cb7f9
commit afe746ecdc
142 changed files with 1258 additions and 907 deletions

View File

@ -1,5 +1,5 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
@ -18,8 +18,8 @@ import { EmployeeService } from '../employee.service';
export class EmployeeDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: FormGroup;
costCentres: CostCentre[];
item: Employee;
costCentres: CostCentre[] = [];
item: Employee = new Employee();
constructor(
private route: ActivatedRoute,
@ -40,7 +40,10 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
joiningDate: '',
leavingDate: '',
});
this.listenToIsActiveChanges();
// Listen to IsActive Changes
(this.form.get('isActive') as FormControl).valueChanges.subscribe((x) => {
this.item.isActive = x;
});
}
ngOnInit() {
@ -73,16 +76,10 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
this.nameElement.nativeElement.focus();
if (this.nameElement) this.nameElement.nativeElement.focus();
}, 0);
}
listenToIsActiveChanges(): void {
this.form.get('isActive').valueChanges.subscribe((x) => {
this.item.isActive = x;
});
}
save() {
this.ser.saveOrUpdate(this.getItem()).subscribe(
() => {
@ -96,7 +93,7 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
}
delete() {
this.ser.delete(this.item.id).subscribe(
this.ser.delete(this.item.id as string).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/employees');