From ebb337d70661254b4449fdb34c1066d9a290b45a Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Mon, 11 Jul 2022 14:56:27 +0200 Subject: [PATCH 1/2] =?UTF-8?q?cr=C3=A9ation=20d'une=20PE=20apr=C3=A8s=20l?= =?UTF-8?q?a=20cr=C3=A9ation=20d'un=20collaborateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collaborateur-add.component.ts | 5 +++- .../periode-essai-add.component.html | 12 ++++++---- .../periode-essai-add.component.ts | 24 ++++++++++++++++--- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts b/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts index 3e6ca9e..13fcb48 100644 --- a/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts +++ b/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts @@ -6,6 +6,7 @@ import {HttpClient} from "@angular/common/http"; import {BusinessunitService} from "../../../services/businessunit.service"; import {CollaborateurService} from "../../../services/collaborateur.service"; import {ToastrService} from "ngx-toastr"; +import {Router} from '@angular/router'; @Component({ selector: 'app-collaborateur-add', @@ -30,7 +31,8 @@ export class CollaborateurAddComponent implements OnInit { private businessunitService: BusinessunitService, private collaborateurService: CollaborateurService, private formBuilder: FormBuilder, - private toastr: ToastrService) { + private toastr: ToastrService, + private router: Router) { } get form() { @@ -82,6 +84,7 @@ export class CollaborateurAddComponent implements OnInit { this.collaborateurService.addCollaborateur(this.collaborateur).subscribe(collaborateur => { this.collaborateurs.push(collaborateur); this.showSuccess(); + this.router.navigateByUrl('/periodeessais/add?apsideMail='+this.registerForm.value.apsideMail); }, () => { this.showError() diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html index c02c27b..3f91d1f 100644 --- a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html +++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.html @@ -4,9 +4,11 @@
- @@ -20,7 +22,8 @@
-
La date de début d'une période d'essai est obligatoire
@@ -29,7 +32,8 @@
-
diff --git a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts index 0d7fd04..7cc0946 100644 --- a/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts +++ b/src/app/components/periode-essai/periode-essai-add/periode-essai-add.component.ts @@ -6,6 +6,7 @@ import {HttpClient} from "@angular/common/http"; import {CollaborateurService} from "../../../services/collaborateur.service"; import {PeriodeEssaiService} from "../../../services/periode-essai.service"; import {ToastrService} from "ngx-toastr"; +import {ActivatedRoute} from "@angular/router"; @Component({ selector: 'app-periode-essai-add', @@ -21,12 +22,16 @@ export class PeriodeEssaiAddComponent implements OnInit { registerForm!: FormGroup; submitted = false; + apsideMail?: string | null; + id?: number; + constructor( private http: HttpClient, private collaborateurService: CollaborateurService, private periodeEssaiService: PeriodeEssaiService, private formBuilder: FormBuilder, - private toastr: ToastrService + private toastr: ToastrService, + private route: ActivatedRoute ) { } @@ -35,7 +40,7 @@ export class PeriodeEssaiAddComponent implements OnInit { } ngOnInit(): void { - this.getCollaborateurs(); + this.apsideMail = this.route.snapshot.queryParamMap.get('apsideMail'); this.registerForm = this.formBuilder.group({ comment: [], collaborateurId: ['', Validators.required], @@ -44,11 +49,24 @@ export class PeriodeEssaiAddComponent implements OnInit { realEndingDate: [], startingDate: ['', Validators.required] }); + + this.getCollaborateurs(); + } getCollaborateurs(): void { this.collaborateurService.getCollaborateurs() - .subscribe(collaborateurs => this.collaborateurs = collaborateurs); + .subscribe(collaborateurs => { + this.collaborateurs = collaborateurs; + if (this.apsideMail != undefined) { + this.collaborateurs.forEach(collab => { + if (this.apsideMail == collab.apsideMail) { + this.registerForm.get("collaborateurId")?.setValue(collab.id) + this.collaborateur = collab + } + }) + } + }); } onSubmit() { From 5b49e5ae32058f90e0a65c8f03e6e10c0bb77b07 Mon Sep 17 00:00:00 2001 From: Clement FERRERE Date: Mon, 11 Jul 2022 14:57:35 +0200 Subject: [PATCH 2/2] reformat code total --- src/app/app.module.ts | 4 ++-- .../components/agence/agence-add/agence-add.component.ts | 2 +- src/app/components/agence/agence.component.ts | 1 - .../businessunit-add/businessunit-add.component.ts | 2 +- src/app/components/businessunit/businessunit.component.ts | 1 - .../collaborateur-add/collaborateur-add.component.ts | 2 +- .../components/periode-essai/periode-essai.component.html | 3 ++- src/app/components/periode-essai/periode-essai.component.ts | 5 ++--- .../referencement-add/referencement-add.component.html | 6 ++++-- .../referencement-edit/referencement-edit.component.html | 6 ++++-- 10 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4cc0082..1cccdde 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,8 +22,8 @@ import {ReferencementComponent} from './components/referencement/referencement.c import {ReferencementAddComponent} from './components/referencement/referencement-add/referencement-add.component'; import {ReferencementEditComponent} from './components/referencement/referencement-edit/referencement-edit.component'; import {PeriodeEssaiAddComponent} from './components/periode-essai/periode-essai-add/periode-essai-add.component'; -import { BusinessunitAddComponent } from './components/businessunit/businessunit-add/businessunit-add.component'; -import { AgenceAddComponent } from './components/agence/agence-add/agence-add.component'; +import {BusinessunitAddComponent} from './components/businessunit/businessunit-add/businessunit-add.component'; +import {AgenceAddComponent} from './components/agence/agence-add/agence-add.component'; @NgModule({ declarations: [ diff --git a/src/app/components/agence/agence-add/agence-add.component.ts b/src/app/components/agence/agence-add/agence-add.component.ts index 75064e2..26cc129 100644 --- a/src/app/components/agence/agence-add/agence-add.component.ts +++ b/src/app/components/agence/agence-add/agence-add.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {Agence} from "../../../interfaces/agence"; import {Businessunit} from "../../../interfaces/businessunit"; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; diff --git a/src/app/components/agence/agence.component.ts b/src/app/components/agence/agence.component.ts index c19d9d1..2f2fe72 100644 --- a/src/app/components/agence/agence.component.ts +++ b/src/app/components/agence/agence.component.ts @@ -52,5 +52,4 @@ export class AgenceComponent implements OnInit { } - } diff --git a/src/app/components/businessunit/businessunit-add/businessunit-add.component.ts b/src/app/components/businessunit/businessunit-add/businessunit-add.component.ts index 69452ae..3cdb975 100644 --- a/src/app/components/businessunit/businessunit-add/businessunit-add.component.ts +++ b/src/app/components/businessunit/businessunit-add/businessunit-add.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {Businessunit} from "../../../interfaces/businessunit"; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import {HttpClient} from "@angular/common/http"; diff --git a/src/app/components/businessunit/businessunit.component.ts b/src/app/components/businessunit/businessunit.component.ts index 2de451e..a3f08ad 100644 --- a/src/app/components/businessunit/businessunit.component.ts +++ b/src/app/components/businessunit/businessunit.component.ts @@ -35,5 +35,4 @@ export class BusinessunitComponent implements OnInit { } - } diff --git a/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts b/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts index 13fcb48..83ba157 100644 --- a/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts +++ b/src/app/components/collaborateur/collaborateur-add/collaborateur-add.component.ts @@ -84,7 +84,7 @@ export class CollaborateurAddComponent implements OnInit { this.collaborateurService.addCollaborateur(this.collaborateur).subscribe(collaborateur => { this.collaborateurs.push(collaborateur); this.showSuccess(); - this.router.navigateByUrl('/periodeessais/add?apsideMail='+this.registerForm.value.apsideMail); + this.router.navigateByUrl('/periodeessais/add?apsideMail=' + this.registerForm.value.apsideMail); }, () => { this.showError() diff --git a/src/app/components/periode-essai/periode-essai.component.html b/src/app/components/periode-essai/periode-essai.component.html index f4e9697..30e214c 100644 --- a/src/app/components/periode-essai/periode-essai.component.html +++ b/src/app/components/periode-essai/periode-essai.component.html @@ -27,7 +27,8 @@ - {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} + {{getCollaborateurById(periodeEssai.collaborateurId).name}} {{getCollaborateurById(periodeEssai.collaborateurId).firstName}} {{getSplitDate(periodeEssai.startingDate.toString())}} {{getSplitDate(periodeEssai.plannedEndingDate.toString())}} {{periodeEssai.issue}} diff --git a/src/app/components/periode-essai/periode-essai.component.ts b/src/app/components/periode-essai/periode-essai.component.ts index 3fec2b8..a051674 100644 --- a/src/app/components/periode-essai/periode-essai.component.ts +++ b/src/app/components/periode-essai/periode-essai.component.ts @@ -38,11 +38,10 @@ export class PeriodeEssaiComponent implements OnInit { this.initPeriodeEssai(); } - initPeriodeEssai(){ + initPeriodeEssai() { if (this.isOld) { this.periodeEssais = this.periodeEssaisPassees; - } - else{ + } else { this.periodeEssais = this.periodeEssaisEnCours; } } diff --git a/src/app/components/referencement/referencement-add/referencement-add.component.html b/src/app/components/referencement/referencement-add/referencement-add.component.html index 43e80ef..8cf45be 100644 --- a/src/app/components/referencement/referencement-add/referencement-add.component.html +++ b/src/app/components/referencement/referencement-add/referencement-add.component.html @@ -6,14 +6,16 @@
-
-
diff --git a/src/app/components/referencement/referencement-edit/referencement-edit.component.html b/src/app/components/referencement/referencement-edit/referencement-edit.component.html index 09e44e3..e7c3d07 100644 --- a/src/app/components/referencement/referencement-edit/referencement-edit.component.html +++ b/src/app/components/referencement/referencement-edit/referencement-edit.component.html @@ -6,7 +6,8 @@
- @@ -14,7 +15,8 @@
-