diff --git a/src/app/components/periode-essai/periode-essai.component.html b/src/app/components/periode-essai/periode-essai.component.html index 2b0f88b..f4e9697 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..3fec2b8 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,21 @@ 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; + } } getCollaborateurs(): void { @@ -46,7 +66,25 @@ 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.periodeEssaisEnCours.sort((b, a) => new Date(b.plannedEndingDate).getTime() - new Date(a.plannedEndingDate).getTime()); + this.periodeEssaisPassees.sort((a, b) => new Date(b.plannedEndingDate).getTime() - new Date(a.plannedEndingDate).getTime()); + 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