|
|
|
@ -1,5 +1,9 @@ |
|
|
|
|
import { Component, Input } from '@angular/core'; |
|
|
|
|
import { EpDTO } from '@shared/api-swagger'; |
|
|
|
|
import { analyzeAndValidateNgModules } from '@angular/compiler'; |
|
|
|
|
import { Component, Inject, Input } from '@angular/core'; |
|
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
|
import { CollaborateurDTO, CommentaireAssistantDTO, EpDTO } from '@shared/api-swagger'; |
|
|
|
|
import { AuthService } from '@shared/auth/auth.service'; |
|
|
|
|
import { Subscription } from 'rxjs'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Composant pour permettre au référent d'ajouter son commentaire et à tous les participants de le consulter |
|
|
|
@ -12,6 +16,116 @@ export class EpCommentairesAssistantComponent { |
|
|
|
|
|
|
|
|
|
@Input() ep : EpDTO; |
|
|
|
|
|
|
|
|
|
constructor() {} |
|
|
|
|
@Input() collaborateurConnecte : CollaborateurDTO; |
|
|
|
|
|
|
|
|
|
dialogAjoutModificationSubscription : Subscription; |
|
|
|
|
dialogSuppressionSubscription : Subscription; |
|
|
|
|
|
|
|
|
|
constructor(private matDialog: MatDialog) {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aDejaCommente() { |
|
|
|
|
return this.ep.commentairesAssistant != undefined && this.ep.commentairesAssistant.some( c => c.idAssistant == this.collaborateurConnecte.id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
nouveauCommentaire() { |
|
|
|
|
this.ouvrirSaisiCommentaire(undefined); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
modifierCommentaire(commentaire : CommentaireAssistantDTO) { |
|
|
|
|
this.ouvrirSaisiCommentaire(commentaire); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
supprimerCommentaire(id : number) { |
|
|
|
|
const dialogRef: MatDialogRef<DialogEPSupprimerCommentaireAssistant> = this.matDialog.open(DialogEPSupprimerCommentaireAssistant); |
|
|
|
|
this.dialogSuppressionSubscription = dialogRef.afterClosed().subscribe( |
|
|
|
|
reponse => { |
|
|
|
|
if(reponse) |
|
|
|
|
this.ep.commentairesAssistant = this.ep.commentairesAssistant.filter( c => c.id != id); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ouvrirSaisiCommentaire(data?: any) { |
|
|
|
|
const dialogRef: MatDialogRef<DialogEPAjouterCommentaireAssistant> = this.matDialog.open(DialogEPAjouterCommentaireAssistant, { data: data}); |
|
|
|
|
this.dialogAjoutModificationSubscription = dialogRef.afterClosed().subscribe( |
|
|
|
|
reponse => { |
|
|
|
|
if(reponse != undefined && reponse.nouveauCommentaire) |
|
|
|
|
this.ajouterCommentaire(reponse.commentaire); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ajouterCommentaire(commentaire : CommentaireAssistantDTO) { |
|
|
|
|
commentaire.idAssistant = this.collaborateurConnecte.id; |
|
|
|
|
commentaire.assistant = this.collaborateurConnecte.nom + " " + this.collaborateurConnecte.prenom; |
|
|
|
|
if(this.ep.commentairesAssistant == undefined) { |
|
|
|
|
this.ep.commentairesAssistant = []; |
|
|
|
|
} |
|
|
|
|
this.ep.commentairesAssistant.push(commentaire); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() { |
|
|
|
|
this.dialogAjoutModificationSubscription?.unsubscribe(); |
|
|
|
|
this.dialogSuppressionSubscription?.unsubscribe(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Composant pour faire afficher un pop up pour l'ajout d'un commentaire assistant |
|
|
|
|
*/ |
|
|
|
|
@Component( { |
|
|
|
|
selector: "dialog-ep-ajouter-commentaire", |
|
|
|
|
templateUrl: "./dialog-ep-ajouter-commentaire-assistant.html" |
|
|
|
|
}) |
|
|
|
|
export class DialogEPAjouterCommentaireAssistant { |
|
|
|
|
commentaire : string = ""; |
|
|
|
|
nouveauCommentaire : boolean = true; |
|
|
|
|
commentaireDTO : CommentaireAssistantDTO; |
|
|
|
|
|
|
|
|
|
constructor(private dialogRef : MatDialogRef<DialogEPAjouterCommentaireAssistant>, @Inject(MAT_DIALOG_DATA) public data: CommentaireAssistantDTO) { |
|
|
|
|
if(data != undefined) { |
|
|
|
|
this.commentaireDTO = data; |
|
|
|
|
this.commentaire = this.commentaireDTO.commentaire; |
|
|
|
|
this.nouveauCommentaire = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enregistrer() { |
|
|
|
|
if(this.nouveauCommentaire) { |
|
|
|
|
this.commentaireDTO = { |
|
|
|
|
idAssistant : "", |
|
|
|
|
commentaire : this.commentaire |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
this.commentaireDTO.commentaire = this.commentaire; |
|
|
|
|
} |
|
|
|
|
const reponse : any = { |
|
|
|
|
nouveauCommentaire: this.nouveauCommentaire, |
|
|
|
|
commentaire : this.commentaireDTO |
|
|
|
|
} |
|
|
|
|
this.dialogRef.close(reponse); |
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
annuler() { |
|
|
|
|
this.dialogRef.close(undefined); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Composant pour afficher un pop permettant la validation ou non de la suppression d'un commentaire |
|
|
|
|
*/ |
|
|
|
|
@Component( { |
|
|
|
|
selector: "dialog-ep-supprimer-commentaire-assistant", |
|
|
|
|
templateUrl: "./dialog-ep-supprimer-commentaire-assistant.html" |
|
|
|
|
}) |
|
|
|
|
export class DialogEPSupprimerCommentaireAssistant { |
|
|
|
|
constructor( private dialogRef: MatDialogRef<DialogEPSupprimerCommentaireAssistant>) {} |
|
|
|
|
|
|
|
|
|
valider(reponse : boolean) { |
|
|
|
|
this.dialogRef.close(reponse); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|