|
|
@ -1,11 +1,9 @@ |
|
|
|
import {Component, OnInit} from '@angular/core'; |
|
|
|
import {Component, OnInit} from '@angular/core'; |
|
|
|
import {HttpClient} from "@angular/common/http"; |
|
|
|
import {HttpClient} from "@angular/common/http"; |
|
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
|
|
|
|
|
|
|
import {PeriodeEssai} from "../../interfaces/periode-essai"; |
|
|
|
import {PeriodeEssai} from "../../interfaces/periode-essai"; |
|
|
|
import {Collaborateur} from "../../interfaces/collaborateur"; |
|
|
|
import {Collaborateur} from "../../interfaces/collaborateur"; |
|
|
|
import {CollaborateurService} from "../../services/collaborateur.service"; |
|
|
|
import {CollaborateurService} from "../../services/collaborateur.service"; |
|
|
|
import {PeriodeEssaiService} from "../../services/periode-essai.service"; |
|
|
|
import {PeriodeEssaiService} from "../../services/periode-essai.service"; |
|
|
|
import {ToastrService} from "ngx-toastr"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-periode-essai', |
|
|
|
selector: 'app-periode-essai', |
|
|
@ -15,33 +13,18 @@ import {ToastrService} from "ngx-toastr"; |
|
|
|
export class PeriodeEssaiComponent implements OnInit { |
|
|
|
export class PeriodeEssaiComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
collaborateurs: Collaborateur[] = []; |
|
|
|
collaborateurs: Collaborateur[] = []; |
|
|
|
collaborateur = {} as Collaborateur; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
periodeEssais: PeriodeEssai[] = []; |
|
|
|
periodeEssais: PeriodeEssai[] = []; |
|
|
|
periodeEssai = {} as PeriodeEssai; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
registerForm!: FormGroup; |
|
|
|
|
|
|
|
submitted = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
private http: HttpClient, |
|
|
|
private http: HttpClient, |
|
|
|
private collaborateurService: CollaborateurService, |
|
|
|
private collaborateurService: CollaborateurService, |
|
|
|
private periodeEssaiService: PeriodeEssaiService, |
|
|
|
private periodeEssaiService: PeriodeEssaiService, |
|
|
|
private formBuilder: FormBuilder, |
|
|
|
) { |
|
|
|
private toastr: ToastrService |
|
|
|
} |
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
this.getCollaborateurs(); |
|
|
|
this.getCollaborateurs(); |
|
|
|
this.getPeriodeEssais(); |
|
|
|
this.getPeriodeEssais(); |
|
|
|
this.registerForm = this.formBuilder.group({ |
|
|
|
|
|
|
|
comment: ['', Validators.required], |
|
|
|
|
|
|
|
collaborateurId: ['',Validators.required], |
|
|
|
|
|
|
|
issue: ['',Validators.required], |
|
|
|
|
|
|
|
plannedEndingDate: ['',Validators.required], |
|
|
|
|
|
|
|
realEndingDate: ['',Validators.required], |
|
|
|
|
|
|
|
startingDate: ['',Validators.required] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getCollaborateurs(): void { |
|
|
|
getCollaborateurs(): void { |
|
|
@ -49,58 +32,21 @@ export class PeriodeEssaiComponent implements OnInit { |
|
|
|
.subscribe(collaborateurs => this.collaborateurs = collaborateurs); |
|
|
|
.subscribe(collaborateurs => this.collaborateurs = collaborateurs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getPeriodeEssais() { |
|
|
|
getCollaborateurById(id : number) : Collaborateur{ |
|
|
|
this.periodeEssaiService.getPeriodeEssais() |
|
|
|
let collab = {} as Collaborateur; |
|
|
|
.subscribe(periodeEssais => this.periodeEssais = periodeEssais); |
|
|
|
this.collaborateurs.forEach(c => { |
|
|
|
} |
|
|
|
if (c.id==id){ |
|
|
|
|
|
|
|
collab= c; |
|
|
|
add(periodeEssai: PeriodeEssai): void { |
|
|
|
|
|
|
|
this.periodeEssaiService.addPeriodeEssai(periodeEssai) |
|
|
|
|
|
|
|
.subscribe(periodeEssai => { |
|
|
|
|
|
|
|
this.periodeEssais.push(periodeEssai); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onSubmit() { |
|
|
|
|
|
|
|
this.submitted = true; |
|
|
|
|
|
|
|
if (this.registerForm.invalid) { |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.periodeEssai.comment = this.registerForm.value.comment |
|
|
|
}); |
|
|
|
this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId |
|
|
|
|
|
|
|
this.periodeEssai.issue = this.registerForm.value.issue |
|
|
|
|
|
|
|
this.periodeEssai.plannedEndingDate = this.registerForm.value.plannedEndingDate |
|
|
|
|
|
|
|
this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate |
|
|
|
|
|
|
|
this.periodeEssai.startingDate = this.registerForm.value.startingDate |
|
|
|
|
|
|
|
this.add(this.periodeEssai) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get f() { return this.registerForm.controls; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onReset() { |
|
|
|
|
|
|
|
this.submitted = false; |
|
|
|
|
|
|
|
this.registerForm.reset(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onStartingDateChange($event: any):void { |
|
|
|
|
|
|
|
this.periodeEssai.startingDate = new Date($event.target.value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onPlannedEndingDateChange($event: any):void { |
|
|
|
|
|
|
|
this.periodeEssai.plannedEndingDate = new Date($event.target.value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onRealEndingDateChange($event: any):void { |
|
|
|
return collab; |
|
|
|
this.periodeEssai.realEndingDate = new Date($event.target.value); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getPeriodeEssais() { |
|
|
|
|
|
|
|
this.periodeEssaiService.getPeriodeEssais() |
|
|
|
showSuccess() { |
|
|
|
.subscribe(periodeEssais => this.periodeEssais = periodeEssais); |
|
|
|
this.toastr.success('Création réussie', 'Collaborateur'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
showError() { |
|
|
|
|
|
|
|
this.toastr.error('Création échouée', 'Collaborateur'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|