parent
288809bf5b
commit
4b025d3502
@ -1 +1,55 @@ |
|||||||
<p>referencement-add works!</p> |
<h3>Ajouter un collaborateur : </h3> |
||||||
|
|
||||||
|
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()"> |
||||||
|
|
||||||
|
<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 && form.startingDate.errors }"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3"> |
||||||
|
<label class="form-label">Date de fin</label> |
||||||
|
<input type="date" class="form-control" formControlName="endingDate" |
||||||
|
(change)="onEndingDateChange($event)" |
||||||
|
[ngClass]="{ 'is-invalid': submitted && form.endingDate.errors }"> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="row mb-2"> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-md-6"> |
||||||
|
<label class="form-label">Référent</label> |
||||||
|
<select class="form-select" formControlName="referrerId" |
||||||
|
[ngClass]="{ 'is-invalid': submitted && form.referrerId.errors }"> |
||||||
|
<option value="" disabled selected>Choisissez le référent du référencement</option> |
||||||
|
<option *ngFor="let collaborateur of collaborateurs" [ngValue]="collaborateur.id">{{collaborateur.name}} </option> |
||||||
|
</select> |
||||||
|
<div *ngIf="submitted && form.referrerId.errors" class="invalid-feedback"> |
||||||
|
<div *ngIf="form.referrerId.errors.required">Vous devez préciser le référent du référencement</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group col-12 col-md-6"> |
||||||
|
<label class="form-label">Référé</label> |
||||||
|
<select class="form-select" formControlName="referredId" |
||||||
|
[ngClass]="{ 'is-invalid': submitted && form.referredId.errors }"> |
||||||
|
<option value="" disabled selected>Choisissez le référé du référencement</option> |
||||||
|
<option *ngFor="let collaborateur of collaborateurs" [ngValue]="collaborateur.id">{{collaborateur.name}} </option> |
||||||
|
</select> |
||||||
|
<div *ngIf="submitted && form.referredId.errors" class="invalid-feedback"> |
||||||
|
<div *ngIf="form.referredId.errors.required">Vous devez préciser le référent du référencement</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<div> |
||||||
|
<button type="submit">Ajouter le référencement</button> |
||||||
|
<button type="reset" (click)="onReset()">Effacer</button> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
@ -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<Referencement[]> { |
||||||
|
return this.http.get<Referencement[]>(this.referencementsUrl); |
||||||
|
} |
||||||
|
|
||||||
|
getReferencement(id : number):Observable<Referencement>{ |
||||||
|
return this.http.get<Referencement>(this.referencementsUrl+"/"+id); |
||||||
|
} |
||||||
|
|
||||||
|
updateReferencement(referencement : Referencement):Observable<Referencement>{ |
||||||
|
let body = JSON.stringify(referencement); |
||||||
|
return this.http.put<Referencement>(this.referencementsUrl + "/" + referencement.id, body, this.httpOptions); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
deleteReferencement(referencement: Referencement) { |
||||||
|
return this.http.delete(this.referencementsUrl + "/" + referencement.id); |
||||||
|
} |
||||||
|
|
||||||
|
addReferencement(referencement: Referencement): Observable<Referencement> { |
||||||
|
let body = JSON.stringify(referencement); |
||||||
|
return this.http.post<Referencement>(this.referencementsUrl, body, this.httpOptions); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -1,3 +1,5 @@ |
|||||||
export const collaborateursUrl = 'https://localhost:5001/api/collaborateurs'; |
export const collaborateursUrl = 'https://localhost:5001/api/collaborateurs'; |
||||||
export const agencesUrl = 'https://localhost:5001/api/agences'; |
export const agencesUrl = 'https://localhost:5001/api/agences'; |
||||||
export const businessunitsUrl = 'https://localhost:5001/api/businessunits'; |
export const businessunitsUrl = 'https://localhost:5001/api/businessunits'; |
||||||
|
export const periodeessaisUrl = 'https://localhost:5001/api/periodeessais'; |
||||||
|
export const referencementsUrl = 'https://localhost:5001/api/referencements'; |
||||||
|
Loading…
Reference in new issue