Séparation periode essai en cours / passées

pull/22/head
Clement FERRERE 2 years ago
parent 5301ad8025
commit 1423298acc
  1. 14
      src/app/components/periode-essai/periode-essai.component.html
  2. 41
      src/app/components/periode-essai/periode-essai.component.ts

@ -1,23 +1,35 @@
<div xmlns=""> <div xmlns="">
<h2 class=mb-4>Périodes d'essai</h2> <h2 *ngIf="isOld" class=mb-4>Périodes d'essai Passées</h2>
<h2 *ngIf="!isOld" class=mb-4>Périodes d'essai En cours</h2>
<div style="display: flex"> <div style="display: flex">
<p style="margin: 10px 0 10px 0">Pour ajouter une nouvelle période d'essai, cliquez ici : </p> <p style="margin: 10px 0 10px 0">Pour ajouter une nouvelle période d'essai, cliquez ici : </p>
<button routerLink="/periodeessais/add">Ajouter</button> <button routerLink="/periodeessais/add">Ajouter</button>
</div> </div>
<br/><br/>
<div style="display: flex">
<p *ngIf="!isOld" style="margin: 10px 0 10px 0">Pour voir les périodes d'essai passées, cliquez ici : </p>
<p *ngIf="isOld" style="margin: 10px 0 10px 0">Pour voir les périodes d'essai en cours, cliquez ici :</p>
<button (click)="onIsOldChange()">Changer</button>
</div>
<div class="mb-5 col-12" style="overflow-x:auto;"> <div class="mb-5 col-12" style="overflow-x:auto;">
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th scope="col">Collaborateur</th> <th scope="col">Collaborateur</th>
<th scope="col">Date de début</th>
<th scope="col">Date de fin prévue</th>
<th scope="col">Issue</th> <th scope="col">Issue</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let periodeEssai of periodeEssais"> <tr *ngFor="let periodeEssai of periodeEssais">
<th scope="row">{{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}}</th> <th scope="row">{{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}}</th>
<td> {{getSplitDate(periodeEssai.startingDate.toString())}}</td>
<td> {{getSplitDate(periodeEssai.plannedEndingDate.toString())}}</td>
<td> {{periodeEssai.issue}}</td> <td> {{periodeEssai.issue}}</td>
<td><a routerLink="{{periodeEssai.id}}"> Modifier </a></td> <td><a routerLink="{{periodeEssai.id}}"> Modifier </a></td>
</tr> </tr>

@ -15,6 +15,11 @@ export class PeriodeEssaiComponent implements OnInit {
collaborateurs: Collaborateur[] = []; collaborateurs: Collaborateur[] = [];
periodeEssais: PeriodeEssai[] = []; periodeEssais: PeriodeEssai[] = [];
periodeEssaisEnCours: PeriodeEssai[] = [];
periodeEssaisPassees: PeriodeEssai[] = [];
isOld: boolean = false;
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private collaborateurService: CollaborateurService, private collaborateurService: CollaborateurService,
@ -25,6 +30,24 @@ export class PeriodeEssaiComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.getCollaborateurs(); this.getCollaborateurs();
this.getPeriodeEssais(); 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 { getCollaborateurs(): void {
@ -46,7 +69,23 @@ export class PeriodeEssaiComponent implements OnInit {
getPeriodeEssais() { getPeriodeEssais() {
this.periodeEssaiService.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];
} }
} }

Loading…
Cancel
Save