diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 28d735c..8cd2d58 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,6 +21,7 @@ import { ToastrModule } from 'ngx-toastr'; import { ReferencementComponent } from './components/referencement/referencement.component'; import { ReferencementAddComponent } from './components/referencement/referencement-add/referencement-add.component'; import { ReferencementEditComponent } from './components/referencement/referencement-edit/referencement-edit.component'; +import { PeriodeEssaiAddComponent } from './components/periode-essai/periode-essai-add/periode-essai-add.component'; @NgModule({ declarations: [ @@ -38,6 +39,7 @@ import { ReferencementEditComponent } from './components/referencement/reference ReferencementComponent, ReferencementAddComponent, ReferencementEditComponent, + PeriodeEssaiAddComponent, ], imports: [ diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html new file mode 100644 index 0000000..424039f --- /dev/null +++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html @@ -0,0 +1,68 @@ +

Ajouter une Période d'essai :

+ +
+ +
+ + +
+
Vous devez choisir le collaborateur concerné par cette période + d'essai +
+
+
+ +
+ + +
+
La date de début d'une période d'essai est obligatoire
+
+
+ +
+ + +
+
La date de fin prévue d'une période d'essai est obligatoire
+
+
+ +
+ + +
+
La date de fin réelle d'une période d'essai est obligatoire
+
+
+ +
+ + +
+
Le commentaire d'une période d'essai est obligatoire
+
+
+ +
+ + +
+
L'issue d'une période d'essai est obligatoire
+
+
+ + +
+ + +
+
diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.scss b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.scss new file mode 100644 index 0000000..e69de29 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 new file mode 100644 index 0000000..9ba085b --- /dev/null +++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts @@ -0,0 +1,96 @@ +import { Component, OnInit } from '@angular/core'; +import {Collaborateur} from "../../../interfaces/collaborateur"; +import {PeriodeEssai} from "../../../interfaces/periode-essai"; +import {FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {HttpClient} from "@angular/common/http"; +import {CollaborateurService} from "../../../services/collaborateur.service"; +import {PeriodeEssaiService} from "../../../services/periode-essai.service"; +import {ToastrService} from "ngx-toastr"; + +@Component({ + selector: 'app-periode-essai-add', + templateUrl: './periode-essai-add.component.html', + styleUrls: ['./periode-essai-add.component.scss'] +}) +export class PeriodeEssaiAddComponent implements OnInit { + + collaborateurs : Collaborateur[] = []; + collaborateur = {} as Collaborateur; + periodeEssai = {} as PeriodeEssai; + + registerForm!: FormGroup; + submitted = false; + + constructor( + private http : HttpClient, + private collaborateurService: CollaborateurService, + private periodeEssaiService: PeriodeEssaiService, + private formBuilder: FormBuilder, + private toastr: ToastrService + ) { } + + 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] + }); + } + + getCollaborateurs():void { + this.collaborateurService.getCollaborateurs() + .subscribe(collaborateurs => this.collaborateurs = collaborateurs); + } + + 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.periodeEssaiService.addPeriodeEssai(this.periodeEssai) + .subscribe(() => { + this.showSuccess(); + }, + () => { + this.showError() + }); + } + + 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 { + this.periodeEssai.realEndingDate = new Date($event.target.value); + } + + showSuccess() { + this.toastr.success('Création réussie', 'Collaborateur'); + } + + showError() { + this.toastr.error('Création échouée', 'Collaborateur'); + } + +} diff --git a/src/app/components/periode-essai/periode-essai.component.html b/src/app/components/periode-essai/periode-essai.component.html index ab4f869..256fd5c 100644 --- a/src/app/components/periode-essai/periode-essai.component.html +++ b/src/app/components/periode-essai/periode-essai.component.html @@ -1,70 +1,6 @@
-

Ajouter une Période d'Essai :

- -
- -
- - -
-
Vous devez choisir le collaborateur concerné par cette période d'essai
-
-
- -
- - -
-
La date de début d'une période d'essai est obligatoire
-
-
- -
- - -
-
La date de fin prévue d'une période d'essai est obligatoire
-
-
- -
- - -
-
La date de fin réelle d'une période d'essai est obligatoire
-
-
- -
- - -
-
Le commentaire d'une période d'essai est obligatoire
-
-
- -
- - -
-
L'issue d'une période d'essai est obligatoire
-
-
- - - - -
- - -
-
- -

Périodes d'essai

+

Périodes d'essai

@@ -80,13 +16,10 @@ - +
{{periodeEssai.id}} {{periodeEssai.collaborateurId}} {{periodeEssai.issue}} Modifier Modifier
- - -
diff --git a/src/app/components/referencement/referencement-add/referencement-add.component.html b/src/app/components/referencement/referencement-add/referencement-add.component.html index 6708dcf..e1cbb0f 100644 --- a/src/app/components/referencement/referencement-add/referencement-add.component.html +++ b/src/app/components/referencement/referencement-add/referencement-add.component.html @@ -1,4 +1,4 @@ -

Ajouter un collaborateur :

+

Ajouter un référencement :

diff --git a/src/app/components/referencement/referencement-add/referencement-add.component.ts b/src/app/components/referencement/referencement-add/referencement-add.component.ts index 75502f3..a07f705 100644 --- a/src/app/components/referencement/referencement-add/referencement-add.component.ts +++ b/src/app/components/referencement/referencement-add/referencement-add.component.ts @@ -16,7 +16,6 @@ export class ReferencementAddComponent implements OnInit { collaborateurs: Collaborateur[] = []; collaborateur = {} as Collaborateur; - referencements: Referencement[] = []; referencement = {} as Referencement; errorValue: number = 0; @@ -35,7 +34,6 @@ export class ReferencementAddComponent implements OnInit { ngOnInit(): void { this.getCollaborateurs(); - this.getReferencements(); this.registerForm = this.formBuilder.group({ referredId: ['', Validators.required], referrerId: ['', Validators.required], @@ -55,11 +53,6 @@ export class ReferencementAddComponent implements OnInit { .subscribe(collaborateurs => this.collaborateurs = collaborateurs); } - getReferencements(): void { - this.referencementService.getReferencements() - .subscribe(referencement => this.referencements = referencement); - } - onSubmit() { this.submitted = true; if (this.registerForm.invalid) { @@ -67,8 +60,7 @@ export class ReferencementAddComponent implements OnInit { } this.referencement = this.registerForm.value if (this.referencement) { - this.referencementService.addReferencement(this.referencement).subscribe(referencement => { - this.referencements.push(referencement); + this.referencementService.addReferencement(this.referencement).subscribe(() => { this.showSuccess(); }, () => { -- 2.36.3 From f3d7ea5b74458a2ad345157091cc79091f141b73 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Tue, 5 Jul 2022 11:23:13 +0200 Subject: [PATCH 2/2] =?UTF-8?q?rework=20complet=20des=20p=C3=A9riodes=20d'?= =?UTF-8?q?essai?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 +- .../periode-essai-add.component.html | 73 ++++++++------- .../periode-essai-add.component.ts | 73 +++++++++------ .../periode-essai-edit.component.html | 24 +++-- .../periode-essai-edit.component.ts | 64 +++++++------ .../periode-essai.component.html | 9 +- .../periode-essai/periode-essai.component.ts | 92 ++++--------------- .../referencement-edit.component.ts | 20 ++-- src/app/interfaces/periode-essai.ts | 2 +- src/app/interfaces/referencement.ts | 2 +- 10 files changed, 170 insertions(+), 195 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1fa907..fed4ab6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# Stage 1 - +# Stage 1 : Building the application FROM node:16-alpine3.14 as build-step RUN mkdir -p /app @@ -12,8 +11,7 @@ RUN npm install RUN npm run build --prod -# Stage 2 - +# Stage 2 : Deploying the application on Nginx FROM nginx:1.17.1-alpine RUN rm -rf /usr/share/nginx/html/* && rm -rf /etc/nginx/nginx.conf diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html index 424039f..29cd394 100644 --- a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html +++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html @@ -7,7 +7,8 @@
Vous devez choisir le collaborateur concerné par cette période @@ -16,51 +17,55 @@
-
- - -
-
La date de début d'une période d'essai est obligatoire
+
+
+ + +
+
La date de début d'une période d'essai est obligatoire
+
-
-
- - -
-
La date de fin prévue d'une période d'essai est obligatoire
+
+ + +
+
La date de fin prévue d'une période d'essai est obligatoire +
+
-
-
- - -
-
La date de fin réelle d'une période d'essai est obligatoire
+
+ +
-
- - -
-
Le commentaire d'une période d'essai est obligatoire
+
+ +
+ +
-
-
- - -
-
L'issue d'une période d'essai est obligatoire
+
+ +
-
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 @@
-
-
La date de fin réelle d'une période d'essai est obligatoire
-
+ formControlName="realEndingDate" (change)="onRealEndingDateChange($event)">
- -
-
Le commentaire d'une période d'essai est obligatoire
-
+
- -
-
L'issue d'une période d'essai est obligatoire
-
+
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 :

+ +
+
- + - + 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; } -- 2.36.3
IDCollaborateur IDCollaborateur Issue
{{periodeEssai.id}} {{periodeEssai.collaborateurId}} {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} {{periodeEssai.issue}} Modifier