From 7f602a2e996016538e29152128168bfe99e9e30c Mon Sep 17 00:00:00 2001 From: Julien DAUPHANT Date: Mon, 6 Jan 2020 16:31:35 +0100 Subject: [PATCH] [122] Afficher le nom du groupe pour inviter une personne (#387) * [122] Afficher le nom du groupe pour inviter une personne * S'assurer que seul les groupes dans la zone s'affiche --- app/controllers/ApplicationController.scala | 7 +++-- app/views/showApplication.scala.html | 32 ++++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/controllers/ApplicationController.scala b/app/controllers/ApplicationController.scala index 98d1fb8a7..c8783a63d 100644 --- a/app/controllers/ApplicationController.scala +++ b/app/controllers/ApplicationController.scala @@ -330,7 +330,10 @@ case class ApplicationController @Inject()(loginAction: LoginAction, case Some(application) => if(application.canBeShowedBy(request.currentUser)) { val usersThatCanBeInvited = usersThatCanBeInvitedOn(application) - + val groups = userGroupService.byIds(usersThatCanBeInvited.flatMap(_.groupIds)).filter(_.areaIds.contains(application.area)) + val groupsWithUsersThatCanBeInvited = groups.map { group => + group -> usersThatCanBeInvited.filter(_.groupIds.contains(group.id)) + } val renderedApplication = if((application.haveUserInvitedOn(request.currentUser) || request.currentUser.id == application.creatorUserId) && request.currentUser.expert && request.currentUser.admin && !application.closed) { // If user is expert, admin and invited to the application we desanonymate applicationService.byId(id, request.currentUser.id, false).get @@ -340,7 +343,7 @@ case class ApplicationController @Inject()(loginAction: LoginAction, val openedTab = request.flash.get("opened-tab").getOrElse("answer") eventService.info("APPLICATION_SHOWED", s"Demande $id consulté", Some(application)) - Ok(views.html.showApplication(request.currentUser)(usersThatCanBeInvited, renderedApplication, answerForm, openedTab)) + Ok(views.html.showApplication(request.currentUser)(groupsWithUsersThatCanBeInvited, renderedApplication, answerForm, openedTab)) } else { eventService.warn("APPLICATION_UNAUTHORIZED", s"L'accès à la demande $id n'est pas autorisé", Some(application)) diff --git a/app/views/showApplication.scala.html b/app/views/showApplication.scala.html index 52ea9a7d4..f3b799bbe 100644 --- a/app/views/showApplication.scala.html +++ b/app/views/showApplication.scala.html @@ -1,4 +1,4 @@ -@(user: User)(usersThatCanBeInvited: List[User], application: Application, answerToAgentsForm: Form[_], openedTab: String, attachments: Iterable[String] = Nil)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, messagesProvider: MessagesProvider, request: RequestHeader) +@(user: User)(groupsWithUsersThatCanBeInvited: List[(UserGroup,List[User])], application: Application, answerToAgentsForm: Form[_], openedTab: String, attachments: Iterable[String] = Nil)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, messagesProvider: MessagesProvider, request: RequestHeader) @import java.util.Locale @main(user)(s"Demande de ${application.creatorUserName} - ${Area.fromId(application.area).get.name}") { @@ -381,7 +381,7 @@

@application.subject

reply_all Ajouter une réponse - @if(usersThatCanBeInvited.nonEmpty) { + @if(groupsWithUsersThatCanBeInvited.nonEmpty) { person_add Inviter une personne } @@ -447,7 +447,7 @@
Ajouter informations concernant l'usager
- @if(usersThatCanBeInvited.nonEmpty) { + @if(groupsWithUsersThatCanBeInvited.nonEmpty) {
@helper.CSRF.formField @@ -455,21 +455,25 @@
Ajouter informations concernant l'usager - Qualité + Structure Nom + Qualité - @for(user <- usersThatCanBeInvited.sortBy(_.qualite)) { - - - - - @user.qualite - @user.name - + @for((group, users) <- groupsWithUsersThatCanBeInvited.sortBy(_._1.name)) { + @for(user <- users.sortBy(_.name)) { + + + + + @group.name + @user.name + @user.qualite + + } }