From 954f1613ef134f0c2cd370db1c05242f9e1a38cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yana=C3=ABl=20GRETTE?= Date: Fri, 12 Feb 2021 11:25:51 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20possibilit=C3=A9=20de=20chang?= =?UTF-8?q?er=20le=20r=C3=A9f=C3=A9rent=20EP=20d'un=20collaborateur=20depu?= =?UTF-8?q?is=20ses=20d=C3=A9tails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assignation-referent.component.ts | 1 + .../affichage-details-collaborateur.html | 6 +- .../affichage-details-collaborateur.module.ts | 4 +- .../affichage-details-collaborateur.ts | 14 +++- ...log-assignation-rapide-collaborateurs.html | 1 + .../dialog-assignation-rapide-referent.html | 8 +++ .../dialog-assignation-rapide.component.ts | 66 +++++++++++++++++++ 7 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-collaborateurs.html create mode 100644 src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-referent.html create mode 100644 src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide.component.ts diff --git a/src/app/referents/assignation-referent/assignation-referent.component.ts b/src/app/referents/assignation-referent/assignation-referent.component.ts index a5f0249..4796684 100644 --- a/src/app/referents/assignation-referent/assignation-referent.component.ts +++ b/src/app/referents/assignation-referent/assignation-referent.component.ts @@ -54,6 +54,7 @@ export class AssignationReferentComponent { } choixReferent(event: any) { + console.log(event); this.referentChoisi = event.collaborateur; this.setCollaborateurEP(); } diff --git a/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.html b/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.html index b60c1d1..0b705ee 100644 --- a/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.html +++ b/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.html @@ -2,12 +2,14 @@

{{ collaborateur.nom }} {{ collaborateur.prenom }}

Agence : {{ collaborateur.businessUnit.nom}} ({{ collaborateur.businessUnit.agence.nom}})

-

Aucun référent

-

Référent : {{ collaborateur.referent.nom }} {{ collaborateur.referent.prenom }}

+

Aucun référent

+

Référent : {{ collaborateur.referent.nom }} {{ collaborateur.referent.prenom }}

Date embauche : {{ collaborateur.dateArrivee | date: 'dd MMMM yyyy'}}

Date départ : {{ collaborateur.dateDepart | date: 'dd MMMM yyyy'}}

+ + diff --git a/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.module.ts b/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.module.ts index e6f49ac..8d0bf88 100644 --- a/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.module.ts +++ b/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.module.ts @@ -5,10 +5,12 @@ import { FormsModule } from '@angular/forms'; import { MaterialModule } from "../angular-material/angular-material.module"; import { AffichageDetailsCollaborateurComponent } from "@shared/affichage-details-collaboarteur/affichage-details-collaborateur"; import { MatTablesModule } from '@shared/mat-tables/mat-tables.module'; +import { DialogAssignationRapideReferentComponent } from "./dialog-assignation-rapide/dialog-assignation-rapide.component"; + @NgModule({ declarations: [ - AffichageDetailsCollaborateurComponent + AffichageDetailsCollaborateurComponent, DialogAssignationRapideReferentComponent ], imports: [ MaterialModule, diff --git a/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.ts b/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.ts index 137bca8..721022f 100644 --- a/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.ts +++ b/src/app/shared/affichage-details-collaboarteur/affichage-details-collaborateur.ts @@ -2,6 +2,9 @@ import { Component, Input, OnInit } from "@angular/core"; import { CollaborateurDTO, CollaborateursService } from "@shared/api-swagger"; import { Subscription } from "rxjs"; import { collaborateurTypeRecherche } from "@shared/utils/cles"; +import { MatDialog } from "@angular/material/dialog"; +import { DialogAssignationRapideReferentComponent } from "./dialog-assignation-rapide/dialog-assignation-rapide.component"; + @Component({ selector: "affichage-details-collaborateur", @@ -22,7 +25,7 @@ export class AffichageDetailsCollaborateurComponent implements OnInit{ collaborateur: CollaborateurDTO = undefined; private collaborateurSubscription: Subscription; - constructor(private collaborateurService: CollaborateursService) {} + constructor(private collaborateurService: CollaborateursService, private dialog: MatDialog) {} ngOnInit() { this.collaborateurSubscription = this.collaborateurService.getCollaborateurById(this.idCollaborateur).subscribe( @@ -36,4 +39,13 @@ export class AffichageDetailsCollaborateurComponent implements OnInit{ this.collaborateurSubscription.unsubscribe(); } } + + openDialog() { + let datas = { data: this.collaborateur, width: "80%", height: '80%'}; + let dialog = DialogAssignationRapideReferentComponent; + if(this.estReferent) + console.log("ui"); + else + this.dialog.open( dialog, datas ); + } } \ No newline at end of file diff --git a/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-collaborateurs.html b/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-collaborateurs.html new file mode 100644 index 0000000..3e8fc5e --- /dev/null +++ b/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-collaborateurs.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-referent.html b/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-referent.html new file mode 100644 index 0000000..4ad2232 --- /dev/null +++ b/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide-referent.html @@ -0,0 +1,8 @@ + + +

{{referentChoisi.nom}} {{referentChoisi.prenom}} {{ estReferentActuel() ? "(Référent actuel)" : "" }}

+ +
+

Veuillez choisir un référent

+ + \ No newline at end of file diff --git a/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide.component.ts b/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide.component.ts new file mode 100644 index 0000000..286b2dd --- /dev/null +++ b/src/app/shared/affichage-details-collaboarteur/dialog-assignation-rapide/dialog-assignation-rapide.component.ts @@ -0,0 +1,66 @@ +import {Component, Inject } from "@angular/core"; +import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; +import { CollaborateurDTO, ReferentEPDTO, ReferentsEPService } from "@shared/api-swagger"; +import { collaborateurTypeRecherche, } from "@shared/utils/cles"; +import { DialogAssignationReferentComponent } from "app/referents/assignation-referent/assignation-referent.component"; +import { Subscription } from "rxjs"; + +@Component({ + selector: "dialog-assignation-rapide-referent", + templateUrl: "dialog-assignation-rapide-referent.html" +}) +export class DialogAssignationRapideReferentComponent { + + rechercherParDate: boolean = false; + + rechercherParBU: boolean = true; + + referentChoisi : CollaborateurDTO = undefined; + + roles : string[] = ["Manager", "RA", "CP", "TL"]; + + + typeRecherche: string = collaborateurTypeRecherche.referents; + + displayedColumns : string[] = ["businessunit", "collaborateur"]; + + private referentEPSubscription: Subscription; + + constructor(private dialogRef: MatDialogRef, private referentsEPService: ReferentsEPService, + @Inject(MAT_DIALOG_DATA) private data: CollaborateurDTO) { + this.referentChoisi = data.referent; + } + + selectionnerReferent(event) { + this.referentChoisi = event.collaborateur; + } + + mettreAJourReferent() { + const referentEPDTO: ReferentEPDTO = { + idReferent : this.referentChoisi.id, + idsCollaborateur : [this.data.id], + }; + + this.referentEPSubscription = this.referentsEPService.updateReferentCollaborateur(referentEPDTO, this.data.id).subscribe( + () => location.reload(), + err => console.log(err) + ); + + } + + estReferentActuel() { + return this.referentChoisi != undefined && this.data.referent != undefined &&this.referentChoisi.id == this.data.referent.id; + } + + annuler() { + this.dialogRef.close(); + } + + onDestroy() { + if(this.referentEPSubscription != undefined) { + this.referentEPSubscription.unsubscribe(); + } + } + + +} \ No newline at end of file