|
|
@ -1,8 +1,8 @@ |
|
|
|
import {Component, Inject } from "@angular/core"; |
|
|
|
import {Component, Inject, OnInit } from "@angular/core"; |
|
|
|
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; |
|
|
|
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; |
|
|
|
import { CollaborateurDTO, ReferentEPDTO, ReferentsEPService } from "@shared/api-swagger"; |
|
|
|
import { MatSnackBar } from "@angular/material/snack-bar"; |
|
|
|
|
|
|
|
import { CollaborateurDTO, CollaborateursService, ReferentEPDTO, ReferentsEPService } from "@shared/api-swagger"; |
|
|
|
import { collaborateurTypeRecherche, } from "@shared/utils/cles"; |
|
|
|
import { collaborateurTypeRecherche, } from "@shared/utils/cles"; |
|
|
|
import { DialogAssignationReferentComponent } from "app/referents/assignation-referent/assignation-referent.component"; |
|
|
|
|
|
|
|
import { Subscription } from "rxjs"; |
|
|
|
import { Subscription } from "rxjs"; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
@ -26,7 +26,7 @@ export class DialogAssignationRapideReferentComponent { |
|
|
|
|
|
|
|
|
|
|
|
private referentEPSubscription: Subscription; |
|
|
|
private referentEPSubscription: Subscription; |
|
|
|
|
|
|
|
|
|
|
|
constructor(private dialogRef: MatDialogRef<DialogAssignationReferentComponent>, private referentsEPService: ReferentsEPService, |
|
|
|
constructor(private dialogRef: MatDialogRef<DialogAssignationRapideReferentComponent>, private referentsEPService: ReferentsEPService, |
|
|
|
@Inject(MAT_DIALOG_DATA) private data: CollaborateurDTO) { |
|
|
|
@Inject(MAT_DIALOG_DATA) private data: CollaborateurDTO) { |
|
|
|
this.referentChoisi = data.referent; |
|
|
|
this.referentChoisi = data.referent; |
|
|
|
} |
|
|
|
} |
|
|
@ -63,4 +63,106 @@ export class DialogAssignationRapideReferentComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
|
|
|
selector: "dialog-assignation-rapide-collaborateurs", |
|
|
|
|
|
|
|
templateUrl: "dialog-assignation-rapide-collaborateurs.html" |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
export class DialogAssignationRapideCollaborateursComponent implements OnInit{ |
|
|
|
|
|
|
|
rechercherParDate: boolean = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rechercherParBU: boolean = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
roles : string[] = ["Collaborateur"]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typeRecherche: string = collaborateurTypeRecherche.collaborateurs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displayedColumns : string[] = ["businessunit", "collaborateur", "datearrivee", "referent"]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collaborateursEP: CollaborateurDTO[] = []; |
|
|
|
|
|
|
|
collaborateursSelectionnes: CollaborateurDTO[] = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private collaborateurSubscription: Subscription; |
|
|
|
|
|
|
|
private referentEPSubscription: Subscription; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private dialogRef: MatDialogRef<DialogAssignationRapideCollaborateursComponent>, private referentsEPService: ReferentsEPService, |
|
|
|
|
|
|
|
private collaborateurService: CollaborateursService, @Inject(MAT_DIALOG_DATA) private data: CollaborateurDTO, |
|
|
|
|
|
|
|
private snackBar: MatSnackBar) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
|
|
|
this.collaborateurSubscription = this.collaborateurService.getCollaborateursByReferent(this.data.id).subscribe( |
|
|
|
|
|
|
|
collaborateurs => this.collaborateursEP = collaborateurs, |
|
|
|
|
|
|
|
err => console.log(err)
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajoutCollaborateur(event:any) { |
|
|
|
|
|
|
|
if(event.type != "collaborateur") |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
if(event.collaborateur.id == this.data.id) { |
|
|
|
|
|
|
|
this.openSnackBar("Un collaborateur ne peut pas être son propre référent"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(this.contientCollaborateur(this.collaborateursSelectionnes, event.collaborateur)){ |
|
|
|
|
|
|
|
this.enleverCollaborateur(event.collaborateur); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(this.contientCollaborateur(this.collaborateursEP, event.collaborateur)){ |
|
|
|
|
|
|
|
this.openSnackBar("Le référent choisi est déjà le référent EP du collaborateur sélectionné") |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.collaborateursSelectionnes.push(event.collaborateur); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contientCollaborateur(listes: CollaborateurDTO[], collaborateur: CollaborateurDTO ) : boolean { |
|
|
|
|
|
|
|
return listes.some(c => c.id == collaborateur.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enleverCollaborateur(collaborateur: CollaborateurDTO) { |
|
|
|
|
|
|
|
this.collaborateursSelectionnes = this.collaborateursSelectionnes.filter(c => c.id != collaborateur.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajouterCollaborateur(event) { |
|
|
|
|
|
|
|
if(event.type == "collaborateur") { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mettreAJourReferentEP() { |
|
|
|
|
|
|
|
const referentEP : ReferentEPDTO = { |
|
|
|
|
|
|
|
idReferent: this.data.id, |
|
|
|
|
|
|
|
idsCollaborateur: this.collaborateursSelectionnes.map( c => c.id) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.referentEPSubscription = this.referentsEPService.updateCollaborateursReferent(referentEP, this.data.id).subscribe( |
|
|
|
|
|
|
|
() => location.reload(), |
|
|
|
|
|
|
|
err => console.log(err) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openSnackBar(message: string) { |
|
|
|
|
|
|
|
this.snackBar.open(message,"", { |
|
|
|
|
|
|
|
duration: 5000, |
|
|
|
|
|
|
|
horizontalPosition: "center", |
|
|
|
|
|
|
|
verticalPosition: "top", |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
annuler() { |
|
|
|
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onDestroy() { |
|
|
|
|
|
|
|
if(this.referentEPSubscription != undefined) { |
|
|
|
|
|
|
|
this.referentEPSubscription.unsubscribe(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(this.collaborateurSubscription != undefined) { |
|
|
|
|
|
|
|
this.collaborateurSubscription.unsubscribe(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |