From ac709ed7fc65680116d683269ac8258478d67340 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Wed, 29 Jun 2022 16:53:48 +0200 Subject: [PATCH 1/8] =?UTF-8?q?referrer=20id=20enlev=C3=A9=20+=20creation?= =?UTF-8?q?=20referencement.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.module.ts | 2 ++ .../collaborateur-add.component.html | 13 ------------- .../collaborateur-add.component.ts | 1 - .../collaborateur-edit.component.html | 11 ----------- .../collaborateur-edit.component.ts | 2 -- src/app/interfaces/collaborateur.ts | 1 - src/app/interfaces/referencement.ts | 7 +++++++ .../referencement/referencement.component.html | 1 + .../referencement/referencement.component.scss | 0 src/app/referencement/referencement.component.ts | 15 +++++++++++++++ 10 files changed, 25 insertions(+), 28 deletions(-) create mode 100644 src/app/interfaces/referencement.ts create mode 100644 src/app/referencement/referencement.component.html create mode 100644 src/app/referencement/referencement.component.scss create mode 100644 src/app/referencement/referencement.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index fe5967b..99f8679 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -18,6 +18,7 @@ import {PeriodeEssaiEditComponent} from './components/periode-essai/periode-essa import {CollaborateurAddComponent} from './components/collaborateur/collaborateur-add/collaborateur-add.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ToastrModule } from 'ngx-toastr'; +import { ReferencementComponent } from './referencement/referencement.component'; @NgModule({ declarations: [ @@ -32,6 +33,7 @@ import { ToastrModule } from 'ngx-toastr'; PeriodeEssaiComponent, PeriodeEssaiEditComponent, CollaborateurAddComponent, + ReferencementComponent, ], imports: [ diff --git a/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.html b/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.html index e0a5a82..53588f2 100644 --- a/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.html +++ b/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.html @@ -140,19 +140,6 @@
-
- - -
-
Vous devez préciser le référent du collaborateur
-
-
-
- - - -
-
Vous devez préciser le référent du collaborateur
-
-
-
+
+ +
+ + +
+ +
+ +
+ +
+ + +
+
Vous devez préciser le référent du référencement
+
+
+ +
+ + +
+
Vous devez préciser le référent du 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 264ea43..75502f3 100644 --- a/src/app/components/referencement/referencement-add/referencement-add.component.ts +++ b/src/app/components/referencement/referencement-add/referencement-add.component.ts @@ -1,4 +1,11 @@ import { Component, OnInit } from '@angular/core'; +import {Collaborateur} from "../../../interfaces/collaborateur"; +import {FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {HttpClient} from "@angular/common/http"; +import {CollaborateurService} from "../../../services/collaborateur.service"; +import {ToastrService} from "ngx-toastr"; +import {ReferencementService} from "../../../services/referencement.service"; +import {Referencement} from "../../../interfaces/referencement"; @Component({ selector: 'app-referencement-add', @@ -7,9 +14,94 @@ import { Component, OnInit } from '@angular/core'; }) export class ReferencementAddComponent implements OnInit { - constructor() { } + collaborateurs: Collaborateur[] = []; + collaborateur = {} as Collaborateur; + referencements: Referencement[] = []; + referencement = {} as Referencement; + + errorValue: number = 0; + rDate: String = ""; + bDate: String = ""; + + registerForm!: FormGroup; + submitted = false; + + constructor(private http: HttpClient, + private referencementService: ReferencementService, + private collaborateurService: CollaborateurService, + private formBuilder: FormBuilder, + private toastr: ToastrService) { + } ngOnInit(): void { + this.getCollaborateurs(); + this.getReferencements(); + this.registerForm = this.formBuilder.group({ + referredId: ['', Validators.required], + referrerId: ['', Validators.required], + startingDate: ['', Validators.required], + endingDate: [], + }); + if (this.referencement.startingDate) { + this.rDate = new Date(this.collaborateur.resignationDate).toISOString().split('T')[0]; + } + if (this.referencement.endingDate) { + this.bDate = new Date(this.collaborateur.birthDate).toISOString().split('T')[0]; + } + } + + getCollaborateurs(): void { + this.collaborateurService.getCollaborateurs() + .subscribe(collaborateurs => this.collaborateurs = collaborateurs); + } + + getReferencements(): void { + this.referencementService.getReferencements() + .subscribe(referencement => this.referencements = referencement); + } + + onSubmit() { + this.submitted = true; + if (this.registerForm.invalid) { + return; + } + this.referencement = this.registerForm.value + if (this.referencement) { + this.referencementService.addReferencement(this.referencement).subscribe(referencement => { + this.referencements.push(referencement); + this.showSuccess(); + }, + () => { + this.showError() + }) + + } + } + + get form() { + return this.registerForm.controls; + } + + onReset() { + this.submitted = false; + this.registerForm.reset(); + } + + onStartingDateChange($event: any): void { + this.collaborateur.resignationDate = new Date($event.target.value); + } + + onEndingDateChange($event: any): void { + this.collaborateur.birthDate = new Date($event.target.value); + } + + showSuccess() { + this.toastr.success('Création réussie', 'Référencement'); + } + + showError() { + this.toastr.error('Création échouée', 'Référencement'); } } + diff --git a/src/app/services/agence.service.ts b/src/app/services/agence.service.ts index a92030f..64c87e0 100644 --- a/src/app/services/agence.service.ts +++ b/src/app/services/agence.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; import {Agence} from "../interfaces/agence"; -import {agencesUrl} from "../../ressources/routes/routesPreprod"; +import {agencesUrl} from "../../ressources/routes/routes"; @Injectable({ providedIn: 'root' diff --git a/src/app/services/businessunit.service.ts b/src/app/services/businessunit.service.ts index dbf35fb..7d10aea 100644 --- a/src/app/services/businessunit.service.ts +++ b/src/app/services/businessunit.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; import {Businessunit} from "../interfaces/businessunit"; -import {businessunitsUrl} from "../../ressources/routes/routesPreprod"; +import {businessunitsUrl} from "../../ressources/routes/routes"; @Injectable({ providedIn: 'root' diff --git a/src/app/services/collaborateur.service.ts b/src/app/services/collaborateur.service.ts index 773ab7d..2515717 100644 --- a/src/app/services/collaborateur.service.ts +++ b/src/app/services/collaborateur.service.ts @@ -2,7 +2,7 @@ import {Collaborateur} from "../interfaces/collaborateur"; import {Injectable} from '@angular/core'; import {Observable} from "rxjs"; import {HttpClient, HttpHeaders} from "@angular/common/http"; -import {collaborateursUrl} from "../../ressources/routes/routesPreprod"; +import {collaborateursUrl} from "../../ressources/routes/routes"; @Injectable({providedIn: 'root'}) diff --git a/src/app/services/periode-essai.service.ts b/src/app/services/periode-essai.service.ts index 4bea51f..53984c0 100644 --- a/src/app/services/periode-essai.service.ts +++ b/src/app/services/periode-essai.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; -import {periodeessaisUrl} from "../../ressources/routes/routesPreprod"; +import {periodeessaisUrl} from "../../ressources/routes/routes"; import {PeriodeEssai} from "../interfaces/periode-essai"; diff --git a/src/app/services/referencement.service.ts b/src/app/services/referencement.service.ts new file mode 100644 index 0000000..3df6a4a --- /dev/null +++ b/src/app/services/referencement.service.ts @@ -0,0 +1,43 @@ +import {Referencement} from "../interfaces/referencement"; +import {Injectable} from '@angular/core'; +import {Observable} from "rxjs"; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {referencementsUrl} from "../../ressources/routes/routes"; + + +@Injectable({providedIn: 'root'}) + +export class ReferencementService { + + private referencementsUrl = referencementsUrl; + + httpOptions = { + headers: new HttpHeaders({ 'Content-Type': 'application/json' }) + }; + + constructor(private http: HttpClient) { } + + getReferencements():Observable { + return this.http.get(this.referencementsUrl); + } + + getReferencement(id : number):Observable{ + return this.http.get(this.referencementsUrl+"/"+id); + } + + updateReferencement(referencement : Referencement):Observable{ + let body = JSON.stringify(referencement); + return this.http.put(this.referencementsUrl + "/" + referencement.id, body, this.httpOptions); + + } + + deleteReferencement(referencement: Referencement) { + return this.http.delete(this.referencementsUrl + "/" + referencement.id); + } + + addReferencement(referencement: Referencement): Observable { + let body = JSON.stringify(referencement); + return this.http.post(this.referencementsUrl, body, this.httpOptions); + + } +} diff --git a/src/ressources/routes/routes.ts b/src/ressources/routes/routes.ts index a4645f5..82743c1 100644 --- a/src/ressources/routes/routes.ts +++ b/src/ressources/routes/routes.ts @@ -1,3 +1,5 @@ export const collaborateursUrl = 'https://localhost:5001/api/collaborateurs'; export const agencesUrl = 'https://localhost:5001/api/agences'; export const businessunitsUrl = 'https://localhost:5001/api/businessunits'; +export const periodeessaisUrl = 'https://localhost:5001/api/periodeessais'; +export const referencementsUrl = 'https://localhost:5001/api/referencements'; diff --git a/src/ressources/routes/routesPreprod.ts b/src/ressources/routes/routesPreprod.ts index a611105..b1a3c3b 100644 --- a/src/ressources/routes/routesPreprod.ts +++ b/src/ressources/routes/routesPreprod.ts @@ -2,3 +2,4 @@ export const collaborateursUrl = 'https://collaborateur-epa.apsdigit.lan/api/col export const agencesUrl = 'https://collaborateur-epa.apsdigit.lan/api/agences'; export const businessunitsUrl = 'https://collaborateur-epa.apsdigit.lan/api/businessunits'; export const periodeessaisUrl = 'https://collaborateur-epa.apsdigit.lan/api/periodeessais'; +export const referencementsUrl = 'https://collaborateur-epa.apsdigit.lan/api/referencements'; From d388efdb3b392304dea001558534804706c0d156 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Thu, 30 Jun 2022 10:18:09 +0200 Subject: [PATCH 5/8] =?UTF-8?q?fix=20r=C3=A9f=C3=A9rencement=20add?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.html | 12 ++++++------ .../referencement-add.component.html | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 3890464..043d823 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -8,19 +8,19 @@ -
- +
+
-
- +
+
- - + +
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 3293fc0..e7517c8 100644 --- a/src/app/components/referencement/referencement-add/referencement-add.component.html +++ b/src/app/components/referencement/referencement-add/referencement-add.component.html @@ -39,7 +39,7 @@
Vous devez préciser le référent du référencement
From 248ccc2e0cdf3920ef92b36a4da8d7e4192e4935 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Thu, 30 Jun 2022 11:25:32 +0200 Subject: [PATCH 6/8] =?UTF-8?q?r=C3=A9f=C3=A9rencement=20liste=20et=20edit?= =?UTF-8?q?=20OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../referencement-edit.component.html | 58 +++++++- .../referencement-edit.component.ts | 126 +++++++++++++++++- .../referencement.component.html | 36 ++++- .../referencement/referencement.component.ts | 18 ++- 4 files changed, 233 insertions(+), 5 deletions(-) diff --git a/src/app/components/referencement/referencement-edit/referencement-edit.component.html b/src/app/components/referencement/referencement-edit/referencement-edit.component.html index dbdcefe..d753bc2 100644 --- a/src/app/components/referencement/referencement-edit/referencement-edit.component.html +++ b/src/app/components/referencement/referencement-edit/referencement-edit.component.html @@ -1 +1,57 @@ -

referencement-edit works!

+

Ajouter un collaborateur :

+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ + +
+
Vous devez préciser le référent du référencement
+
+
+ +
+ + +
+
Vous devez préciser le référent du référencement
+
+
+ +
+ +
+ + + + +
+
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 fcf6222..73ecc39 100644 --- a/src/app/components/referencement/referencement-edit/referencement-edit.component.ts +++ b/src/app/components/referencement/referencement-edit/referencement-edit.component.ts @@ -1,4 +1,15 @@ import { Component, OnInit } from '@angular/core'; +import {Collaborateur} from "../../../interfaces/collaborateur"; +import {Referencement} from "../../../interfaces/referencement"; +import {FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {HttpClient} from "@angular/common/http"; +import {ReferencementService} from "../../../services/referencement.service"; +import {CollaborateurService} from "../../../services/collaborateur.service"; +import {ToastrService} from "ngx-toastr"; +import {Location} from "@angular/common"; +import {ActivatedRoute} from "@angular/router"; +import {Observable} from "rxjs"; +import {take, tap} from "rxjs/operators"; @Component({ selector: 'app-referencement-edit', @@ -7,9 +18,120 @@ import { Component, OnInit } from '@angular/core'; }) export class ReferencementEditComponent implements OnInit { - constructor() { } + referencementObservable! : Observable; + id: number; - ngOnInit(): void { + collaborateurs: Collaborateur[] = []; + collaborateur = {} as Collaborateur; + referencements: Referencement[] = []; + referencement = {} as Referencement; + + errorValue: number = 0; + rDate: String = ""; + bDate: String = ""; + + registerForm!: FormGroup; + submitted = false; + + constructor(private http: HttpClient, + private referencementService: ReferencementService, + private collaborateurService: CollaborateurService, + private formBuilder: FormBuilder, + private location: Location, + private route: ActivatedRoute, + private toastr: ToastrService) { + this.id = Number(this.route.snapshot.paramMap.get('id')) + } + + async ngOnInit() { + this.getCollaborateurs(); + this.getReferencements(); + this.registerForm = this.formBuilder.group({ + referredId: ['', Validators.required], + referrerId: ['', Validators.required], + startingDate: ['', Validators.required], + endingDate: [], + }); + + this.referencementObservable = this.referencementService.getReferencement(this.id).pipe(tap(ref => this.registerForm.patchValue(ref))) + this.referencement = await this.referencementObservable.pipe(take(1)).toPromise() + + if (this.referencement.startingDate) { + this.rDate = new Date(this.referencement.startingDate).toISOString().split('T')[0]; + } + if (this.referencement.endingDate) { + this.bDate = new Date(this.referencement.endingDate).toISOString().split('T')[0]; + } + } + + getCollaborateurs(): void { + this.collaborateurService.getCollaborateurs() + .subscribe(collaborateurs => this.collaborateurs = collaborateurs); + } + + getReferencements(): void { + this.referencementService.getReferencements() + .subscribe(referencement => this.referencements = referencement); + } + + onSubmit() { + this.submitted = true; + if (this.registerForm.invalid) { + return; + } + 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.referredId = this.registerForm.value.referredId + } + + if (this.referencement) { + this.referencementService.updateReferencement(this.referencement).subscribe(() => { + this.showSuccess(); + }, + () => { + this.showError() + }) + + } + } + + get form() { + return this.registerForm.controls; + } + + onReset() { + this.submitted = false; + this.registerForm.reset(); + } + + onStartingDateChange($event: any): void { + this.collaborateur.resignationDate = new Date($event.target.value); + } + + onEndingDateChange($event: any): void { + this.collaborateur.birthDate = new Date($event.target.value); + } + + showSuccess() { + this.toastr.success('Modification réussie', 'Référencement'); + } + + showError() { + this.toastr.error('Modification échouée', 'Référencement'); + } + + goBack(): void { + this.location.back(); + } + + delete():void { + if (this.referencement){ + this.referencementService.deleteReferencement(this.referencement) + .subscribe(()=>this.goBack()); + } } } diff --git a/src/app/components/referencement/referencement.component.html b/src/app/components/referencement/referencement.component.html index be015e7..e99fd38 100644 --- a/src/app/components/referencement/referencement.component.html +++ b/src/app/components/referencement/referencement.component.html @@ -1 +1,35 @@ -

referencement works!

+
+ +

Référencements

+ +
+

Pour ajouter un nouveau référencement, cliquez ici :

+ +
+ + +
+ + + + + + + + + + + + + + + + + + + +
Id du référentID du référéDate de débutDate de fin
{{referencement.referrerId}} {{referencement.referredId}} {{referencement.startingDate}} {{referencement.endingDate}} Modifier
+
+ + +
diff --git a/src/app/components/referencement/referencement.component.ts b/src/app/components/referencement/referencement.component.ts index 7c4acfd..682efa0 100644 --- a/src/app/components/referencement/referencement.component.ts +++ b/src/app/components/referencement/referencement.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {ReferencementService} from "../../services/referencement.service"; +import {Referencement} from "../../interfaces/referencement"; @Component({ selector: 'app-referencement', @@ -7,9 +10,22 @@ import { Component, OnInit } from '@angular/core'; }) export class ReferencementComponent implements OnInit { - constructor() { } + referencements: Referencement[] = []; + + constructor( + private http: HttpClient, + private referencementService: ReferencementService, + ) { + } ngOnInit(): void { + this.getReferencements(); + + } + + getReferencements(): void { + this.referencementService.getReferencements() + .subscribe(referencements => this.referencements = referencements); } } From 52843ddfff231c12877df32e677b98d5d3b69022 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Thu, 30 Jun 2022 11:34:23 +0200 Subject: [PATCH 7/8] =?UTF-8?q?up=20routes=20pr=C3=A9prod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/services/agence.service.ts | 2 +- src/app/services/businessunit.service.ts | 2 +- src/app/services/collaborateur.service.ts | 2 +- src/app/services/periode-essai.service.ts | 2 +- src/app/services/referencement.service.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/services/agence.service.ts b/src/app/services/agence.service.ts index 64c87e0..a92030f 100644 --- a/src/app/services/agence.service.ts +++ b/src/app/services/agence.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; import {Agence} from "../interfaces/agence"; -import {agencesUrl} from "../../ressources/routes/routes"; +import {agencesUrl} from "../../ressources/routes/routesPreprod"; @Injectable({ providedIn: 'root' diff --git a/src/app/services/businessunit.service.ts b/src/app/services/businessunit.service.ts index 7d10aea..dbf35fb 100644 --- a/src/app/services/businessunit.service.ts +++ b/src/app/services/businessunit.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; import {Businessunit} from "../interfaces/businessunit"; -import {businessunitsUrl} from "../../ressources/routes/routes"; +import {businessunitsUrl} from "../../ressources/routes/routesPreprod"; @Injectable({ providedIn: 'root' diff --git a/src/app/services/collaborateur.service.ts b/src/app/services/collaborateur.service.ts index 2515717..773ab7d 100644 --- a/src/app/services/collaborateur.service.ts +++ b/src/app/services/collaborateur.service.ts @@ -2,7 +2,7 @@ import {Collaborateur} from "../interfaces/collaborateur"; import {Injectable} from '@angular/core'; import {Observable} from "rxjs"; import {HttpClient, HttpHeaders} from "@angular/common/http"; -import {collaborateursUrl} from "../../ressources/routes/routes"; +import {collaborateursUrl} from "../../ressources/routes/routesPreprod"; @Injectable({providedIn: 'root'}) diff --git a/src/app/services/periode-essai.service.ts b/src/app/services/periode-essai.service.ts index 53984c0..4bea51f 100644 --- a/src/app/services/periode-essai.service.ts +++ b/src/app/services/periode-essai.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {Observable} from "rxjs"; -import {periodeessaisUrl} from "../../ressources/routes/routes"; +import {periodeessaisUrl} from "../../ressources/routes/routesPreprod"; import {PeriodeEssai} from "../interfaces/periode-essai"; diff --git a/src/app/services/referencement.service.ts b/src/app/services/referencement.service.ts index 3df6a4a..e4a7664 100644 --- a/src/app/services/referencement.service.ts +++ b/src/app/services/referencement.service.ts @@ -2,7 +2,7 @@ import {Referencement} from "../interfaces/referencement"; import {Injectable} from '@angular/core'; import {Observable} from "rxjs"; import {HttpClient, HttpHeaders} from "@angular/common/http"; -import {referencementsUrl} from "../../ressources/routes/routes"; +import {referencementsUrl} from "../../ressources/routes/routesPreprod"; @Injectable({providedIn: 'root'}) From 449cd4a72214db431738ec233744504cb30a396b Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Mon, 4 Jul 2022 10:34:57 +0200 Subject: [PATCH 8/8] =?UTF-8?q?Rework=20de=20l'UI=20sur=20les=20r=C3=A9f?= =?UTF-8?q?=C3=A9rencements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../referencement-add.component.html | 2 +- .../referencement-edit.component.html | 4 +-- .../referencement.component.html | 12 ++++---- .../referencement/referencement.component.ts | 28 +++++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) 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 e7517c8..6708dcf 100644 --- a/src/app/components/referencement/referencement-add/referencement-add.component.html +++ b/src/app/components/referencement/referencement-add/referencement-add.component.html @@ -27,7 +27,7 @@
Vous devez préciser le référent du référencement
diff --git a/src/app/components/referencement/referencement-edit/referencement-edit.component.html b/src/app/components/referencement/referencement-edit/referencement-edit.component.html index d753bc2..5d849df 100644 --- a/src/app/components/referencement/referencement-edit/referencement-edit.component.html +++ b/src/app/components/referencement/referencement-edit/referencement-edit.component.html @@ -1,4 +1,4 @@ -

Ajouter un collaborateur :

+

Modifier un collaborateur :

@@ -27,7 +27,7 @@
Vous devez préciser le référent du référencement
diff --git a/src/app/components/referencement/referencement.component.html b/src/app/components/referencement/referencement.component.html index e99fd38..706c2bd 100644 --- a/src/app/components/referencement/referencement.component.html +++ b/src/app/components/referencement/referencement.component.html @@ -12,8 +12,8 @@ - - + + @@ -21,10 +21,10 @@ - - - - + + + + diff --git a/src/app/components/referencement/referencement.component.ts b/src/app/components/referencement/referencement.component.ts index 682efa0..9a6b3e3 100644 --- a/src/app/components/referencement/referencement.component.ts +++ b/src/app/components/referencement/referencement.component.ts @@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {ReferencementService} from "../../services/referencement.service"; import {Referencement} from "../../interfaces/referencement"; +import {CollaborateurService} from "../../services/collaborateur.service"; +import {Collaborateur} from "../../interfaces/collaborateur"; @Component({ selector: 'app-referencement', @@ -11,16 +13,35 @@ import {Referencement} from "../../interfaces/referencement"; export class ReferencementComponent implements OnInit { referencements: Referencement[] = []; + collaborateurs: Collaborateur[]= []; constructor( private http: HttpClient, private referencementService: ReferencementService, + private collaborateurService: CollaborateurService, ) { } ngOnInit(): void { this.getReferencements(); + this.getCollaborateurs(); + } + + getCollaborateurs(): void { + this.collaborateurService.getCollaborateurs() + .subscribe(collaborateurs => this.collaborateurs = collaborateurs); + } + getCollaborateurById(id : number) : Collaborateur{ + let collab = {} as Collaborateur; + this.collaborateurs.forEach(c => { + if (c.id==id){ + collab= c; + return; + } + }); + + return collab; } getReferencements(): void { @@ -28,4 +49,11 @@ export class ReferencementComponent implements OnInit { .subscribe(referencements => this.referencements = referencements); } + getSplitDate(date: string | undefined) : string{ + if (date == undefined){ + return ""; + } + return date.split('T')[0]; + } + }
Id du référentID du référéRéférentRéféré Date de début Date de fin
{{referencement.referrerId}} {{referencement.referredId}} {{referencement.startingDate}} {{referencement.endingDate}} {{getCollaborateurById(referencement.referrerId).name}} {{getCollaborateurById(referencement.referrerId).firstName}} {{getCollaborateurById(referencement.referredId).name}} {{getCollaborateurById(referencement.referredId).firstName}} {{getSplitDate(referencement.startingDate.toString())}} {{getSplitDate(referencement.endingDate?.toString())}} Modifier