diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts
index 9ba085b..0d7fd04 100644
--- a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts
+++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {Collaborateur} from "../../../interfaces/collaborateur";
import {PeriodeEssai} from "../../../interfaces/periode-essai";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
@@ -14,7 +14,7 @@ import {ToastrService} from "ngx-toastr";
})
export class PeriodeEssaiAddComponent implements OnInit {
- collaborateurs : Collaborateur[] = [];
+ collaborateurs: Collaborateur[] = [];
collaborateur = {} as Collaborateur;
periodeEssai = {} as PeriodeEssai;
@@ -22,26 +22,31 @@ export class PeriodeEssaiAddComponent implements OnInit {
submitted = false;
constructor(
- private http : HttpClient,
+ private http: HttpClient,
private collaborateurService: CollaborateurService,
private periodeEssaiService: PeriodeEssaiService,
private formBuilder: FormBuilder,
private toastr: ToastrService
- ) { }
+ ) {
+ }
+
+ get f() {
+ return this.registerForm.controls;
+ }
ngOnInit(): void {
this.getCollaborateurs();
this.registerForm = this.formBuilder.group({
- comment: ['', Validators.required],
- collaborateurId: ['',Validators.required],
- issue: ['',Validators.required],
- plannedEndingDate: ['',Validators.required],
- realEndingDate: ['',Validators.required],
- startingDate: ['',Validators.required]
+ comment: [],
+ collaborateurId: ['', Validators.required],
+ issue: [],
+ plannedEndingDate: ['', Validators.required],
+ realEndingDate: [],
+ startingDate: ['', Validators.required]
});
}
- getCollaborateurs():void {
+ getCollaborateurs(): void {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
}
@@ -51,46 +56,54 @@ export class PeriodeEssaiAddComponent implements OnInit {
if (this.registerForm.invalid) {
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.periodeEssai.comment = this.registerForm.value.comment;
+ this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId;
+ if (this.registerForm.value.issue == undefined) {
+ this.periodeEssai.issue = "INDETERMINEE";
+ } else {
+ this.periodeEssai.issue = this.registerForm.value.issue;
+ }
+ if (this.registerForm.value.realEndingDate == undefined) {
+ this.periodeEssai.realEndingDate = new Date();
+ } else {
+ this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate;
+ }
+ this.periodeEssai.plannedEndingDate = this.registerForm.value.plannedEndingDate;
+ this.periodeEssai.startingDate = this.registerForm.value.startingDate;
+
this.periodeEssaiService.addPeriodeEssai(this.periodeEssai)
- .subscribe(() => {
- this.showSuccess();
- },
- () => {
- this.showError()
- });
+ .subscribe(() => {
+ this.showSuccess();
+ },
+ () => {
+ this.showError()
+ });
}
- get f() { return this.registerForm.controls; }
-
onReset() {
this.submitted = false;
this.registerForm.reset();
}
- onStartingDateChange($event: any):void {
+ onStartingDateChange($event: any): void {
this.periodeEssai.startingDate = new Date($event.target.value);
}
- onPlannedEndingDateChange($event: any):void {
+ onPlannedEndingDateChange($event: any): void {
this.periodeEssai.plannedEndingDate = new Date($event.target.value);
}
- onRealEndingDateChange($event: any):void {
+ onRealEndingDateChange($event: any): void {
this.periodeEssai.realEndingDate = new Date($event.target.value);
}
showSuccess() {
- this.toastr.success('Création réussie', 'Collaborateur');
+ this.toastr.success('Création réussie', 'Période d\'essai');
}
showError() {
- this.toastr.error('Création échouée', 'Collaborateur');
+ this.toastr.error('Création échouée', 'Période d\'essai');
}
}
diff --git a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
index 964cc0a..65199e1 100644
--- a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
+++ b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.html
@@ -45,27 +45,25 @@
diff --git a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
index c540b68..4421e23 100644
--- a/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
+++ b/src/app/components/periode-essai/periode-essai-edit/periode-essai-edit.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {PeriodeEssai} from "../../../interfaces/periode-essai";
import {Collaborateur} from "../../../interfaces/collaborateur";
@@ -17,13 +17,13 @@ import {ToastrService} from "ngx-toastr";
})
export class PeriodeEssaiEditComponent implements OnInit {
- periodeEssaiObservable! : Observable
;
+ periodeEssaiObservable!: Observable;
id: number;
- collaborateurs : Collaborateur[] = [];
+ collaborateurs: Collaborateur[] = [];
collaborateur = {} as Collaborateur;
- periodeEssais : PeriodeEssai[] = [];
+ periodeEssais: PeriodeEssai[] = [];
periodeEssai = {} as PeriodeEssai;
registerForm!: FormGroup;
@@ -40,22 +40,26 @@ export class PeriodeEssaiEditComponent implements OnInit {
this.id = Number(this.route.snapshot.paramMap.get('id'))
}
+ get f() {
+ return this.registerForm.controls;
+ }
+
async ngOnInit() {
this.getCollaborateurs();
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]
+ comment: [],
+ collaborateurId: ['', Validators.required],
+ issue: [],
+ plannedEndingDate: ['', Validators.required],
+ realEndingDate: [],
+ startingDate: ['', Validators.required]
});
this.periodeEssaiObservable = this.periodeEssaiService.getPeriodeEssai(this.id).pipe(tap(pe => this.registerForm.patchValue(pe)))
this.periodeEssai = await this.periodeEssaiObservable.pipe(take(1)).toPromise()
}
- getCollaborateurs():void {
+ getCollaborateurs(): void {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
}
@@ -69,10 +73,10 @@ export class PeriodeEssaiEditComponent implements OnInit {
this.location.back();
}
- delete():void {
- if (this.periodeEssai){
+ delete(): void {
+ if (this.periodeEssai) {
this.periodeEssaiService.deletePeriodeEssai(this.periodeEssai)
- .subscribe(()=>this.goBack());
+ .subscribe(() => this.goBack());
}
}
@@ -82,17 +86,23 @@ export class PeriodeEssaiEditComponent implements OnInit {
if (this.registerForm.invalid) {
return;
}
- this.periodeEssai.comment = this.registerForm.value.comment
- this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId
- this.periodeEssai.issue = this.registerForm.value.issue
- this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate
- this.periodeEssai.startingDate = this.registerForm.value.startingDate
-
- if (this.registerForm.value.plannedEndingDate == undefined) {
- this.periodeEssai.plannedEndingDate = new Date();
+
+ this.periodeEssai.comment = this.registerForm.value.comment;
+ this.periodeEssai.collaborateurId = this.registerForm.value.collaborateurId;
+ if (this.registerForm.value.issue == undefined) {
+ this.periodeEssai.issue = "INDETERMINEE";
+ } else {
+ this.periodeEssai.issue = this.registerForm.value.issue;
}
+ if (this.registerForm.value.realEndingDate == undefined || this.registerForm.value.realEndingDate == '') {
+ this.periodeEssai.realEndingDate = null;
+ } else {
+ this.periodeEssai.realEndingDate = this.registerForm.value.realEndingDate;
+ }
+ this.periodeEssai.plannedEndingDate = this.registerForm.value.plannedEndingDate;
+ this.periodeEssai.startingDate = this.registerForm.value.startingDate;
- if (this.periodeEssai){
+ if (this.periodeEssai) {
this.periodeEssaiService.updatePeriodeEssai(this.periodeEssai)
.subscribe(() => {
this.showSuccess();
@@ -103,22 +113,20 @@ export class PeriodeEssaiEditComponent implements OnInit {
}
}
- get f() { return this.registerForm.controls; }
-
onReset() {
this.submitted = false;
this.registerForm.reset();
}
- onStartingDateChange($event: any):void {
+ onStartingDateChange($event: any): void {
this.periodeEssai.startingDate = new Date($event.target.value);
}
- onPlannedEndingDateChange($event: any):void {
+ onPlannedEndingDateChange($event: any): void {
this.periodeEssai.plannedEndingDate = new Date($event.target.value);
}
- onRealEndingDateChange($event: any):void {
+ onRealEndingDateChange($event: any): void {
this.periodeEssai.realEndingDate = new Date($event.target.value);
}
diff --git a/src/app/components/periode-essai/periode-essai.component.html b/src/app/components/periode-essai/periode-essai.component.html
index 256fd5c..42f1e41 100644
--- a/src/app/components/periode-essai/periode-essai.component.html
+++ b/src/app/components/periode-essai/periode-essai.component.html
@@ -2,19 +2,24 @@
Périodes d'essai
+
+
Pour ajouter une nouvelle période d'essai, cliquez ici :
+
+
+
ID |
- Collaborateur ID |
+ Collaborateur |
Issue |
{{periodeEssai.id}} |
- {{periodeEssai.collaborateurId}} |
+ {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} |
{{periodeEssai.issue}} |
Modifier |
diff --git a/src/app/components/periode-essai/periode-essai.component.ts b/src/app/components/periode-essai/periode-essai.component.ts
index 877fd5b..8d34044 100644
--- a/src/app/components/periode-essai/periode-essai.component.ts
+++ b/src/app/components/periode-essai/periode-essai.component.ts
@@ -1,11 +1,9 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http";
-import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {PeriodeEssai} from "../../interfaces/periode-essai";
import {Collaborateur} from "../../interfaces/collaborateur";
import {CollaborateurService} from "../../services/collaborateur.service";
import {PeriodeEssaiService} from "../../services/periode-essai.service";
-import {ToastrService} from "ngx-toastr";
@Component({
selector: 'app-periode-essai',
@@ -14,93 +12,41 @@ import {ToastrService} from "ngx-toastr";
})
export class PeriodeEssaiComponent implements OnInit {
- collaborateurs : Collaborateur[] = [];
- collaborateur = {} as Collaborateur;
-
- periodeEssais : PeriodeEssai[] = [];
- periodeEssai = {} as PeriodeEssai;
-
- registerForm!: FormGroup;
- submitted = false;
+ collaborateurs: Collaborateur[] = [];
+ periodeEssais: PeriodeEssai[] = [];
constructor(
- private http : HttpClient,
+ private http: HttpClient,
private collaborateurService: CollaborateurService,
private periodeEssaiService: PeriodeEssaiService,
- private formBuilder: FormBuilder,
- private toastr: ToastrService
- ) { }
+ ) {
+ }
ngOnInit(): void {
this.getCollaborateurs();
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 {
this.collaborateurService.getCollaborateurs()
.subscribe(collaborateurs => this.collaborateurs = collaborateurs);
}
- getPeriodeEssais() {
- this.periodeEssaiService.getPeriodeEssais()
- .subscribe(periodeEssais => this.periodeEssais = periodeEssais);
- }
-
- add(periodeEssai: PeriodeEssai): void {
- this.periodeEssaiService.addPeriodeEssai(periodeEssai)
- .subscribe(periodeEssai => {
- this.periodeEssais.push(periodeEssai);
- });
- }
-
- onSubmit() {
- this.submitted = true;
- if (this.registerForm.invalid) {
- 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);
- }
+ getCollaborateurById(id : number) : Collaborateur{
+ let collab = {} as Collaborateur;
+ this.collaborateurs.forEach(c => {
+ if (c.id==id){
+ collab= c;
+ return;
+ }
+ });
- onRealEndingDateChange($event: any):void {
- this.periodeEssai.realEndingDate = new Date($event.target.value);
+ return collab;
}
-
-
- showSuccess() {
- this.toastr.success('Création réussie', 'Collaborateur');
+ getPeriodeEssais() {
+ this.periodeEssaiService.getPeriodeEssais()
+ .subscribe(periodeEssais => this.periodeEssais = periodeEssais);
}
- showError() {
- this.toastr.error('Création échouée', 'Collaborateur');
- }
}
diff --git a/src/app/components/referencement/referencement-edit/referencement-edit.component.ts b/src/app/components/referencement/referencement-edit/referencement-edit.component.ts
index f468a03..8edcb6f 100644
--- a/src/app/components/referencement/referencement-edit/referencement-edit.component.ts
+++ b/src/app/components/referencement/referencement-edit/referencement-edit.component.ts
@@ -40,6 +40,10 @@ export class ReferencementEditComponent implements OnInit {
this.id = Number(this.route.snapshot.paramMap.get('id'))
}
+ get form() {
+ return this.registerForm.controls;
+ }
+
async ngOnInit() {
this.getCollaborateurs();
this.registerForm = this.formBuilder.group({
@@ -65,12 +69,14 @@ export class ReferencementEditComponent implements OnInit {
return;
}
- this.referencement.referredId = this.registerForm.value.referredId
- this.referencement.referrerId = this.registerForm.value.referrerId
- this.referencement.startingDate = this.registerForm.value.startingDate
+ this.referencement.referredId = this.registerForm.value.referredId;
+ this.referencement.referrerId = this.registerForm.value.referrerId;
+ this.referencement.startingDate = this.registerForm.value.startingDate;
- if (this.registerForm.value.endingDate == undefined) {
- this.referencement.endingDate = new Date()
+ if (this.registerForm.value.endingDate == undefined || this.registerForm.value.endingDate == '') {
+ this.referencement.endingDate = null;
+ } else {
+ this.referencement.endingDate = this.registerForm.value.endingDate;
}
if (this.referencement) {
@@ -84,10 +90,6 @@ export class ReferencementEditComponent implements OnInit {
}
}
- get form() {
- return this.registerForm.controls;
- }
-
onReset() {
this.submitted = false;
this.registerForm.reset();
diff --git a/src/app/interfaces/periode-essai.ts b/src/app/interfaces/periode-essai.ts
index 7ffc318..2f73c8b 100644
--- a/src/app/interfaces/periode-essai.ts
+++ b/src/app/interfaces/periode-essai.ts
@@ -3,7 +3,7 @@ export interface PeriodeEssai {
collaborateurId : number;
startingDate : Date;
plannedEndingDate : Date;
- realEndingDate : Date;
+ realEndingDate : Date | null;
comment : string;
issue : string;
}
diff --git a/src/app/interfaces/referencement.ts b/src/app/interfaces/referencement.ts
index 005c7b1..8961bd9 100644
--- a/src/app/interfaces/referencement.ts
+++ b/src/app/interfaces/referencement.ts
@@ -1,7 +1,7 @@
export interface Referencement {
id: number;
startingDate : Date;
- endingDate? : Date;
+ endingDate : Date | null;
referredId : number;
referrerId : number;
}