Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrige le bug de la vue admin de la liste des demandes #1871

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions app/controllers/ApplicationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -518,6 +519,7 @@ case class ApplicationController @Inject() (
val filters = ApplicationsInfos.Filters(
selectedGroups = selectedGroupsFilter,
status = statusFilter,
urlBase = urlBase,
)

val allApplications = applicationService.allOpenOrRecentForUserId(
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions app/models/formModels.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) = {
Expand Down