3ème MR fix_periode_essai à faire #19
Merged
AlexandreRuiz
merged 2 commits from fix_periode_essai
into develop
3 years ago
@ -0,0 +1,73 @@ |
|||||||
|
<h3>Ajouter une Période d'essai : </h3> |
||||||
|
|
||||||
|
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()"> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-md-6"> |
||||||
|
<label class="form-label">Collaborateur</label> |
||||||
|
<select class="form-select" formControlName="collaborateurId" id="collaborateur-select" |
||||||
|
[ngClass]="{ 'is-invalid': submitted && f.collaborateurId.errors }"> |
||||||
|
<option value="" disabled selected>Choisissez le collaborateur concerné par cette période d'essai</option> |
||||||
|
<option *ngFor="let collaborateur of collaborateurs" |
||||||
|
[ngValue]="collaborateur.id">{{collaborateur.name}} {{collaborateur.firstName}}</option> |
||||||
|
</select> |
||||||
|
<div *ngIf="submitted && f.collaborateurId.errors" class="invalid-feedback"> |
||||||
|
<div *ngIf="f.collaborateurId.errors.required">Vous devez choisir le collaborateur concerné par cette période |
||||||
|
d'essai |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="row mb-2"> |
||||||
|
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
||||||
|
<label class="form-label">Date de début</label> |
||||||
|
<input type="date" class="form-control" formControlName="startingDate" (change)="onStartingDateChange($event)" |
||||||
|
[ngClass]="{ 'is-invalid': submitted && f.startingDate.errors }"> |
||||||
|
<div *ngIf="submitted && f.startingDate.errors" class="invalid-feedback"> |
||||||
|
<div *ngIf="f.startingDate.errors.required">La date de début d'une période d'essai est obligatoire</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
||||||
|
<label class="form-label">Date de fin prévue</label> |
||||||
|
<input type="date" class="form-control" formControlName="plannedEndingDate" |
||||||
|
(change)="onPlannedEndingDateChange($event)" |
||||||
|
[ngClass]="{ 'is-invalid': submitted && f.plannedEndingDate.errors }"> |
||||||
|
<div *ngIf="submitted && f.plannedEndingDate.errors" class="invalid-feedback"> |
||||||
|
<div *ngIf="f.plannedEndingDate.errors.required">La date de fin prévue d'une période d'essai est obligatoire |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
||||||
|
<label class="form-label">Date de fin réelle</label> |
||||||
|
<input type="date" class="form-control" formControlName="realEndingDate" |
||||||
|
(change)="onRealEndingDateChange($event)"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="row mb-2"> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2"> |
||||||
|
<label class="form-label">Commentaire</label> |
||||||
|
<input class="form-control" formControlName="comment" [ngClass]="{ 'is-invalid': submitted && f.comment.errors }"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2"> |
||||||
|
<label class="form-label">Issue</label> |
||||||
|
<select class="form-select" formControlName="issue"> |
||||||
|
<option value="" disabled selected>Statut</option> |
||||||
|
<option value="VALIDEE">Validée</option> |
||||||
|
<option value="PROLONGEE_COLLAB">Prolongée par le collaborateur</option> |
||||||
|
<option value="PROLONGEE_APSIDE">Prolongée par Apside</option> |
||||||
|
<option value="ARRETEE_COLLAB">Arrêtée par le collaborateur</option> |
||||||
|
<option value="ARRETEE_APSIDE">Arrêtée par Apside</option> |
||||||
|
<option value="INDETERMINEE">Indéterminée</option> |
||||||
|
</select> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div> |
||||||
|
<button type="submit">Créer la période d'essai</button> |
||||||
|
<button type="reset" (click)="onReset()">Effacer</button> |
||||||
|
</div> |
||||||
|
</form> |
@ -0,0 +1,109 @@ |
|||||||
|
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 |
||||||
|
) { |
||||||
|
} |
||||||
|
|
||||||
|
get f() { |
||||||
|
return this.registerForm.controls; |
||||||
|
} |
||||||
|
|
||||||
|
ngOnInit(): void { |
||||||
|
this.getCollaborateurs(); |
||||||
|
this.registerForm = this.formBuilder.group({ |
||||||
|
comment: [], |
||||||
|
collaborateurId: ['', Validators.required], |
||||||
|
issue: [], |
||||||
|
plannedEndingDate: ['', Validators.required], |
||||||
|
realEndingDate: [], |
||||||
|
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; |
||||||
|
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() |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
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', 'Période d\'essai'); |
||||||
|
} |
||||||
|
|
||||||
|
showError() { |
||||||
|
this.toastr.error('Création échouée', 'Période d\'essai'); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,92 +1,30 @@ |
|||||||
<div xmlns=""> |
<div xmlns=""> |
||||||
|
|
||||||
<h3>Ajouter une Période d'Essai : </h3> |
<h2 class=mb-4>Périodes d'essai</h2> |
||||||
|
|
||||||
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()" > |
<div style="display: flex"> |
||||||
|
<p style="margin: 10px 0 10px 0">Pour ajouter une nouvelle période d'essai, cliquez ici : </p> |
||||||
<div class="form-group col-12 col-md-6"> |
<button routerLink="/periodeessais/add">Ajouter</button> |
||||||
<label class="form-label">Collaborateur</label> |
</div> |
||||||
<select class="form-select" formControlName="collaborateurId" id="collaborateur-select" [ngClass]="{ 'is-invalid': submitted && f.collaborateurId.errors }"> |
|
||||||
<option value="" disabled selected>Choisissez le collaborateur concerné par cette période d'essai</option> |
|
||||||
<option *ngFor="let collaborateur of collaborateurs" [ngValue]="collaborateur.id">{{collaborateur.name}}</option> |
|
||||||
</select> |
|
||||||
<div *ngIf="submitted && f.collaborateurId.errors" class="invalid-feedback"> |
|
||||||
<div *ngIf="f.collaborateurId.errors.required">Vous devez choisir le collaborateur concerné par cette période d'essai </div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
|
||||||
<label class="form-label">Date de début</label> |
|
||||||
<input type="date" class="form-control" formControlName="startingDate" (change)="onStartingDateChange($event)" [ngClass]="{ 'is-invalid': submitted && f.startingDate.errors }"> |
|
||||||
<div *ngIf="submitted && f.startingDate.errors" class="invalid-feedback"> |
|
||||||
<div *ngIf="f.startingDate.errors.required">La date de début d'une période d'essai est obligatoire</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
|
||||||
<label class="form-label">Date de fin prévue</label> |
|
||||||
<input type="date" class="form-control" formControlName="plannedEndingDate" (change)="onPlannedEndingDateChange($event)" [ngClass]="{ 'is-invalid': submitted && f.plannedEndingDate.errors }"> |
|
||||||
<div *ngIf="submitted && f.plannedEndingDate.errors" class="invalid-feedback"> |
|
||||||
<div *ngIf="f.plannedEndingDate.errors.required">La date de fin prévue d'une période d'essai est obligatoire</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
|
||||||
<label class="form-label">Date de fin réelle</label> |
|
||||||
<input type="date" class="form-control" formControlName="realEndingDate" (change)="onRealEndingDateChange($event)" [ngClass]="{ 'is-invalid': submitted && f.realEndingDate.errors }"> |
|
||||||
<div *ngIf="submitted && f.realEndingDate.errors" class="invalid-feedback"> |
|
||||||
<div *ngIf="f.realEndingDate.errors.required">La date de fin réelle d'une période d'essai est obligatoire</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2"> |
|
||||||
<label class="form-label">Commentaire</label> |
|
||||||
<input class="form-control" formControlName="comment" [ngClass]="{ 'is-invalid': submitted && f.comment.errors }"> |
|
||||||
<div *ngIf="submitted && f.comment.errors" class="invalid-feedback"> |
|
||||||
<div *ngIf="f.comment.errors.required">Le commentaire d'une période d'essai est obligatoire</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 mb-2"> |
|
||||||
<label class="form-label">Issue</label> |
|
||||||
<input class="form-control" formControlName="issue" [ngClass]="{ 'is-invalid': submitted && f.issue.errors }"> |
|
||||||
<div *ngIf="submitted && f.issue.errors" class="invalid-feedback"> |
|
||||||
<div *ngIf="f.issue.errors.required">L'issue d'une période d'essai est obligatoire</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div> |
|
||||||
<button type="submit">Créer la période d'essai</button> |
|
||||||
<button type="reset" (click)="onReset()">Effacer</button> |
|
||||||
</div> |
|
||||||
</form> |
|
||||||
|
|
||||||
<h2 class = mb-4>Périodes d'essai</h2> |
|
||||||
|
|
||||||
<div style="overflow-x:auto;" class="mb-5 col-12"> |
<div style="overflow-x:auto;" class="mb-5 col-12"> |
||||||
<table class="table"> |
<table class="table"> |
||||||
<thead> |
<thead> |
||||||
<tr> |
<tr> |
||||||
<th scope="col">ID</th> |
<th scope="col">ID</th> |
||||||
<th scope="col">Collaborateur ID</th> |
<th scope="col">Collaborateur</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">{{periodeEssai.id}}</th> |
<th scope="row">{{periodeEssai.id}}</th> |
||||||
<td> {{periodeEssai.collaborateurId}} </td> |
<td> {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} </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> |
||||||
</tbody> |
</tbody> |
||||||
</table> |
</table> |
||||||
</div> |
</div> |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div> |
</div> |
||||||
|
@ -1,7 +1,7 @@ |
|||||||
export interface Referencement { |
export interface Referencement { |
||||||
id: number; |
id: number; |
||||||
startingDate : Date; |
startingDate : Date; |
||||||
endingDate? : Date; |
endingDate : Date | null; |
||||||
referredId : number; |
referredId : number; |
||||||
referrerId : number; |
referrerId : number; |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue