Skip to content

Commit

Permalink
Corrige le formulaire ajout de groupe de l’ancienne page utilisateurs (
Browse files Browse the repository at this point in the history
  • Loading branch information
niladic authored Jul 13, 2021
1 parent 5d81b38 commit 2871447
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 72 deletions.
110 changes: 110 additions & 0 deletions app/views/addGroup.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package views

import cats.syntax.all._
import controllers.routes.GroupController
import helpers.forms.CSRFInput
import models.{Area, Organisation, User}
import play.api.mvc.RequestHeader
import scalatags.Text.all._

object addGroup {

def innerForm(currentUser: User, selectedArea: Area)(implicit request: RequestHeader): Tag =
div(
cls := "mdl-cell mdl-cell--12-col mdl-grid",
h4(
cls := "mdl-cell mdl-cell--12-col",
"Ajouter un groupe"
),
br,
form(
action := GroupController.addGroup.path,
method := GroupController.addGroup.method,
cls := "mdl-cell mdl-cell--9-col",
CSRFInput,
div(
cls := "mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label",
input(
cls := "mdl-textfield__input",
`type` := "text",
id := "name",
name := "name",
maxlength := models.UserGroup.nameMaxLength
),
label(
cls := "mdl-textfield__label",
`for` := "name",
"Nom du groupe"
)
),
div(
cls := "mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label",
input(
cls := "mdl-textfield__input",
`type` := "text",
id := "description",
name := "description"
),
label(cls := "mdl-textfield__label", `for` := "description", "Description du groupe")
),
div(
cls := "mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label",
input(
cls := "mdl-textfield__input",
`type` := "text",
id := "email",
name := "email",
maxlength := "200"
),
label(
cls := "mdl-textfield__label",
`for` := "email",
"Email du groupe (BAL générique pour inscription et notification, champ facultatif)"
)
),
div(
cls := "mdl-cell mdl-cell--12-col",
select(
id := "organisation",
name := "organisation",
option(
selected,
value := "",
"Organisme non-référencé"
),
Organisation.all.map(organisation =>
option(
value := organisation.id.id,
s"${organisation.shortName} : ${organisation.name}"
)
)
)
),
div(
cls := "mdl-cell mdl-cell--12-col",
select(
cls := "use-slimselect",
id := "area-ids",
name := "area-ids[]",
multiple,
size := "5",
currentUser.areas
.flatMap(Area.fromId)
.map(area =>
option(
value := area.id.toString,
(selectedArea.id === area.id).some.filter(identity).map(_ => selected),
area.name
)
)
)
),
button(
cls := "mdl-button mdl-js-button mdl-button--raised",
`type` := "submit",
"Ajouter le groupe"
)
)
)

}
37 changes: 1 addition & 36 deletions app/views/allUsersByGroup.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,42 +155,7 @@
}
}
@if(currentUser.admin) {
<div class="mdl-cell mdl-cell--12-col mdl-grid">
<h4 class="mdl-cell mdl-cell--12-col">Ajouter un groupe</h4> <br>
@helper.form(routes.GroupController.addGroup, "method" -> "post", "class" -> "mdl-cell mdl-cell--9-col") {
@helper.CSRF.formField
<div class="mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="name" name="name" maxlength="50">
<label class="mdl-textfield__label" for="name">Nom du groupe</label>
</div>
<div class="mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="description" name="description">
<label class="mdl-textfield__label" for="description">Description du groupe</label>
</div>
<div class="mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="email" name="email" maxlength="200">
<label class="mdl-textfield__label" for="email">Email du groupe (BAL générique pour inscription et notification, champ facultatif)</label>
</div>
<div class="mdl-cell mdl-cell--12-col">
<select id="organisation" name="organisation">
<option selected style="font-weight: bold;" value="">Organisme non-référencé</option>
@for(organisation <- Organisation.all) {
<option value="@organisation.shortName">@organisation.shortName : @organisation.name</option>
}
</select>
</div>
<div class="mdl-cell mdl-cell--12-col">
<select id="area-ids" name="area-ids[]" multiple size="5" >
@for(area <- currentUser.areas.flatMap(Area.fromId)) {
<option value="@area.id" @if(selectedArea.id === area.id) { selected }>@area.name</option>
}
</select>
</div>
<button class="mdl-button mdl-js-button mdl-button--raised" type="submit">
Ajouter le groupe
</button>
}
</div>
@toHtml(views.addGroup.innerForm(currentUser, selectedArea))
}
}{
}
37 changes: 1 addition & 36 deletions app/views/allUsersNew.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,42 +239,7 @@
</script>

@if(currentUser.admin) {
<div class="mdl-cell mdl-cell--12-col mdl-grid">
<h4 class="mdl-cell mdl-cell--12-col">Ajouter un groupe</h4> <br>
@helper.form(routes.GroupController.addGroup, "method" -> "post", "class" -> "mdl-cell mdl-cell--9-col") {
@helper.CSRF.formField
<div class="mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="name" name="name" maxlength="@models.UserGroup.nameMaxLength">
<label class="mdl-textfield__label" for="name">Nom du groupe</label>
</div>
<div class="mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="description" name="description">
<label class="mdl-textfield__label" for="description">Description du groupe</label>
</div>
<div class="mdl-cell mdl-cell--12-col mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="email" name="email" maxlength="200">
<label class="mdl-textfield__label" for="email">Email du groupe (BAL générique pour inscription et notification, champ facultatif)</label>
</div>
<div class="mdl-cell mdl-cell--12-col">
<select id="organisation" name="organisation">
<option selected style="font-weight: bold;" value="">Organisme non-référencé</option>
@for(organisation <- Organisation.all) {
<option value="@organisation.id.id">@organisation.shortName : @organisation.name</option>
}
</select>
</div>
<div class="mdl-cell mdl-cell--12-col">
<select class="use-slimselect" id="area-ids" name="area-ids[]" multiple size="5" >
@for(area <- currentUser.areas.flatMap(Area.fromId)) {
<option value="@area.id" @if(selectedArea.id == area.id) { selected }>@area.name</option>
}
</select>
</div>
<button class="mdl-button mdl-js-button mdl-button--raised" type="submit">
Ajouter le groupe
</button>
}
</div>
@toHtml(views.addGroup.innerForm(currentUser, selectedArea))
}
}{
}

0 comments on commit 2871447

Please sign in to comment.