|
|
|
@ -6,6 +6,7 @@ import {HttpClient} from "@angular/common/http"; |
|
|
|
|
import {CollaborateurService} from "../../../services/collaborateur.service"; |
|
|
|
|
import {PeriodeEssaiService} from "../../../services/periode-essai.service"; |
|
|
|
|
import {ToastrService} from "ngx-toastr"; |
|
|
|
|
import {ActivatedRoute} from "@angular/router"; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-periode-essai-add', |
|
|
|
@ -21,12 +22,16 @@ export class PeriodeEssaiAddComponent implements OnInit { |
|
|
|
|
registerForm!: FormGroup; |
|
|
|
|
submitted = false; |
|
|
|
|
|
|
|
|
|
apsideMail?: string | null; |
|
|
|
|
id?: number; |
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
private http: HttpClient, |
|
|
|
|
private collaborateurService: CollaborateurService, |
|
|
|
|
private periodeEssaiService: PeriodeEssaiService, |
|
|
|
|
private formBuilder: FormBuilder, |
|
|
|
|
private toastr: ToastrService |
|
|
|
|
private toastr: ToastrService, |
|
|
|
|
private route: ActivatedRoute |
|
|
|
|
) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -35,7 +40,7 @@ export class PeriodeEssaiAddComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.getCollaborateurs(); |
|
|
|
|
this.apsideMail = this.route.snapshot.queryParamMap.get('apsideMail'); |
|
|
|
|
this.registerForm = this.formBuilder.group({ |
|
|
|
|
comment: [], |
|
|
|
|
collaborateurId: ['', Validators.required], |
|
|
|
@ -44,11 +49,24 @@ export class PeriodeEssaiAddComponent implements OnInit { |
|
|
|
|
realEndingDate: [], |
|
|
|
|
startingDate: ['', Validators.required] |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.getCollaborateurs(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getCollaborateurs(): void { |
|
|
|
|
this.collaborateurService.getCollaborateurs() |
|
|
|
|
.subscribe(collaborateurs => this.collaborateurs = collaborateurs); |
|
|
|
|
.subscribe(collaborateurs => { |
|
|
|
|
this.collaborateurs = collaborateurs; |
|
|
|
|
if (this.apsideMail != undefined) { |
|
|
|
|
this.collaborateurs.forEach(collab => { |
|
|
|
|
if (this.apsideMail == collab.apsideMail) { |
|
|
|
|
this.registerForm.get("collaborateurId")?.setValue(collab.id) |
|
|
|
|
this.collaborateur = collab |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onSubmit() { |
|
|
|
|