From 1423298acc728790241ef6f030f88d54cf5b9425 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Fri, 8 Jul 2022 09:54:42 +0200 Subject: [PATCH] =?UTF-8?q?S=C3=A9paration=20periode=20essai=20en=20cours?= =?UTF-8?q?=20/=20pass=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../periode-essai.component.html | 14 ++++++- .../periode-essai/periode-essai.component.ts | 41 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/app/components/periode-essai/periode-essai.component.html b/src/app/components/periode-essai/periode-essai.component.html index 2b0f88b..e3efd24 100644 --- a/src/app/components/periode-essai/periode-essai.component.html +++ b/src/app/components/periode-essai/periode-essai.component.html @@ -1,23 +1,35 @@
-

Périodes d'essai

+

Périodes d'essai Passées

+

Périodes d'essai En cours

Pour ajouter une nouvelle période d'essai, cliquez ici :

+

+ +
+

Pour voir les périodes d'essai passées, cliquez ici :

+

Pour voir les périodes d'essai en cours, 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 2d2d565..3e70844 100644 --- a/src/app/components/periode-essai/periode-essai.component.ts +++ b/src/app/components/periode-essai/periode-essai.component.ts @@ -15,6 +15,11 @@ export class PeriodeEssaiComponent implements OnInit { collaborateurs: Collaborateur[] = []; periodeEssais: PeriodeEssai[] = []; + periodeEssaisEnCours: PeriodeEssai[] = []; + periodeEssaisPassees: PeriodeEssai[] = []; + + isOld: boolean = false; + constructor( private http: HttpClient, private collaborateurService: CollaborateurService, @@ -25,6 +30,24 @@ export class PeriodeEssaiComponent implements OnInit { ngOnInit(): void { this.getCollaborateurs(); this.getPeriodeEssais(); + + } + + onIsOldChange() { + this.isOld = !this.isOld; + this.initPeriodeEssai(); + } + + initPeriodeEssai(){ + if (this.isOld) { + this.periodeEssais = this.periodeEssaisPassees; + } + else{ + this.periodeEssais = this.periodeEssaisEnCours; + } + console.log(this.periodeEssais) + console.log(this.periodeEssaisEnCours) + console.log(this.periodeEssaisPassees) } getCollaborateurs(): void { @@ -46,7 +69,23 @@ export class PeriodeEssaiComponent implements OnInit { getPeriodeEssais() { this.periodeEssaiService.getPeriodeEssais() - .subscribe(periodeEssais => this.periodeEssais = periodeEssais); + .subscribe(periodeEssais => { + periodeEssais.forEach(pe => { + if (new Date(pe.plannedEndingDate).getTime() > new Date().getTime()) { + this.periodeEssaisEnCours.push(pe); + } else { + this.periodeEssaisPassees.push(pe); + } + }) + this.initPeriodeEssai(); + }); + } + + getSplitDate(date: string | undefined): string { + if (date == undefined) { + return ""; + } + return date.split('T')[0]; } }
CollaborateurDate de débutDate de fin prévue Issue
{{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} {{getSplitDate(periodeEssai.startingDate.toString())}} {{getSplitDate(periodeEssai.plannedEndingDate.toString())}} {{periodeEssai.issue}} Modifier