From ec350ad64db0749ef3d4549cb1a475a0e43ff58e Mon Sep 17 00:00:00 2001 From: niladic Date: Tue, 28 Nov 2023 17:00:40 +0100 Subject: [PATCH] Corrige le bug de la vue admin de la liste des demandes --- app/controllers/ApplicationController.scala | 18 +++++++++++++++--- app/models/formModels.scala | 7 +++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controllers/ApplicationController.scala b/app/controllers/ApplicationController.scala index 567cd3821..f6e105b52 100644 --- a/app/controllers/ApplicationController.scala +++ b/app/controllers/ApplicationController.scala @@ -508,7 +508,8 @@ case class ApplicationController @Inject() ( private def myApplicationsBoard( user: User, userRights: Authorization.UserRights, - asAdmin: Boolean + asAdmin: Boolean, + urlBase: String, )(log: ApplicationsInfos => Unit)(implicit request: play.api.mvc.RequestHeader): Future[Result] = userGroupService.byIdsFuture(user.groupIds).map { userGroups => val selectedGroupsFilter = request.queryString @@ -518,6 +519,7 @@ case class ApplicationController @Inject() ( val filters = ApplicationsInfos.Filters( selectedGroups = selectedGroupsFilter, status = statusFilter, + urlBase = urlBase, ) val allApplications = applicationService.allOpenOrRecentForUserId( @@ -633,7 +635,12 @@ case class ApplicationController @Inject() ( def myApplications: Action[AnyContent] = loginAction.async { implicit request => - myApplicationsBoard(request.currentUser, request.rights, request.currentUser.admin) { infos => + myApplicationsBoard( + request.currentUser, + request.rights, + request.currentUser.admin, + controllers.routes.ApplicationController.myApplications.url + ) { infos => eventService.log( MyApplicationsShowed, s"Visualise la liste des demandes : ${infos.countsLog}" @@ -780,7 +787,12 @@ case class ApplicationController @Inject() ( errorInvolvesUser = Some(otherUser.id) ) { () => LoginAction.readUserRights(otherUser).flatMap { userRights => - myApplicationsBoard(otherUser, userRights, request.currentUser.admin) { infos => + myApplicationsBoard( + otherUser, + userRights, + request.currentUser.admin, + controllers.routes.ApplicationController.allAs(userId).url + ) { infos => eventService .log( AllAsShowed, diff --git a/app/models/formModels.scala b/app/models/formModels.scala index 4943eac7e..65d167370 100644 --- a/app/models/formModels.scala +++ b/app/models/formModels.scala @@ -457,7 +457,7 @@ object formModels { val statusLate = "souffrante" val statusArchived = "archive" - case class Filters(selectedGroups: Option[Set[UUID]], status: Option[String]) { + case class Filters(selectedGroups: Option[Set[UUID]], status: Option[String], urlBase: String) { def groupIsFiltered(id: UUID): Boolean = selectedGroups.map(groups => groups.contains(id)).getOrElse(false) @@ -470,15 +470,14 @@ object formModels { def hasNoStatus: Boolean = !isMine && !isNew && !isProcessing && !isLate && !isArchived def toUrl: String = { - val base = controllers.routes.ApplicationController.myApplications.url val groups: List[String] = selectedGroups.map(_.map(id => s"$groupFilterKey=$id").toList).getOrElse(Nil) val statusFilter: List[String] = status.toList.map(status => s"$statusFilterKey=$status") val filters = statusFilter ::: groups if (filters.isEmpty) - base + urlBase else - base + "?" + filters.mkString("&") + urlBase + "?" + filters.mkString("&") } def withGroup(id: UUID) = {