From 41dad395b2ddc65836607b8151ebebfc09dc2034 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 14:56:47 +0200 Subject: [PATCH] Users management rework --- public/javascripts/admin/users.js | 2 +- views/admin/users/add.pug | 67 ++++++++++++++++-------------- views/admin/users/edit.pug | 68 +++++++++++++++++-------------- views/admin/users/index.pug | 24 ++++++----- 4 files changed, 88 insertions(+), 73 deletions(-) diff --git a/public/javascripts/admin/users.js b/public/javascripts/admin/users.js index fffb243..f7b1213 100644 --- a/public/javascripts/admin/users.js +++ b/public/javascripts/admin/users.js @@ -1,4 +1,4 @@ -document.querySelectorAll("a.remove") +document.querySelectorAll(".delete") .forEach(e => e.addEventListener("click", ev => { if (!confirm("Do you really want to remove this user ?")) ev.preventDefault(); diff --git a/views/admin/users/add.pug b/views/admin/users/add.pug index d085264..811f721 100644 --- a/views/admin/users/add.pug +++ b/views/admin/users/add.pug @@ -1,34 +1,41 @@ extends ../../layout block content - div.card#usersManagement + div.container h1=__("admin.new")+" "+__("admin.user") - form(action="/admin/users/add" method="POST") - h1=__("register.title") - div.field - label(for="username")=__("username") + ":" - input#username(type="text" name="username" required) - div.field - label(for="email")=__("email") + ":" - input#email(type="email" name="email" required) - div.field - label(for="firstName")=__("firstName") + ":" - input#firstName(type="text" name="firstName" required) - div.field - label(for="lastName")=__("lastName") + ":" - input#lastName(type="text" name="lastName" required) - div.field - label(for="department")=__("department") + ":" - +list("department", "department-list", "department", "", "off", true) - div.field - label(for="password")=__("password") + ":" - input#password(type="password" name="password" required) - div.field - label(for="permissions")=__("admin.permissions") - input#permissions(type="number" min="0" max="3" value="0" name="permissions") - div.field - input(type="submit" value=__("register.submit")) - - datalist#department-list - each department in departments - option(value=department.name) + div.row + form(action="/admin/users/add" method="POST") + h1=__("register.title") + div.row + div.input-field.col.s12 + input#username(type="text" name="username" required) + label(for="username")=__("username") + ":" + div.row + div.input-field.col.s12 + input#email(type="email" name="email" required) + label(for="email")=__("email") + ":" + div.row + div.input-field.col.s6 + input#firstName(type="text" name="firstName" required) + label(for="firstName")=__("firstName") + ":" + div.input-field.col.s6 + input#lastName(type="text" name="lastName" required) + label(for="lastName")=__("lastName") + ":" + div.row + div.input-field.col.s12 + select(name="department" required) + option(value="" disabled selected hidden)=__("chooseDepartment") + each department in departments + option(value=department.name)=department.name + label=__("department") + ":" + div.row + div.input-field.col.s12 + input#password(type="password" name="password" required) + label(for="password")=__("password") + ":" + div.row + div.input-field.col.s12 + input#permissions(type="number" min="0" max="3" value="0" name="permissions") + label(for="permissions")=__("admin.permissions") + div.row.center + div.input-field.col.s12 + +submit(__("register.submit")) diff --git a/views/admin/users/edit.pug b/views/admin/users/edit.pug index ea1c399..73b8a3b 100644 --- a/views/admin/users/edit.pug +++ b/views/admin/users/edit.pug @@ -1,35 +1,41 @@ extends ../../layout block content - div.card#sandwichesManagement + div.container h1=__("admin.edit")+" "+targetUser.username - form(action="/admin/users/edit" method="POST") - h2=__("profile.infos") - input.hide(type="text" name="oldUsername" value=targetUser.username required) - div.field - label(for="username")=__("username") + ":" - input#username(type="text" name="username" value=targetUser.username required) - div.field - label(for="email")=__("email") + ":" - input#email(type="email" name="email" value=targetUser.email required) - div.field - label(for="firstName")=__("firstName") + ":" - input#firstName(type="text" name="firstName" value=targetUser.firstName required) - div.field - label(for="lastName")=__("lastName") + ":" - input#lastName(type="text" name="lastName" value=targetUser.lastName required) - div.field - label(for="department")=__("department") + ":" - +list("department", "department-list", "department", targetUser.DepartmentName, "off", true) - div.field - label(for="password")=__("password") + ":" - input#password(type="password" name="password") - div.field - label(for="permissions")=__("admin.permissions") - input#permissions(type="number" min="0" max="3" value=targetUser.permissions name="permissions") - div.field - input(type="submit" value=__("save")) - - datalist#department-list - each department in departments - option(value=department.name) + div.row + form(action="/admin/users/edit" method="POST") + h2=__("profile.infos") + input.hide(type="text" name="oldUsername" value=targetUser.username required) + div.row + div.input-field.col.s12 + input#username(type="text" name="username" value=targetUser.username required) + label(for="username")=__("username") + ":" + div.row + div.input-field.col.s12 + input#email(type="email" name="email" value=targetUser.email required) + label(for="email")=__("email") + ":" + div.row + div.input-field.col.s6 + input#firstName(type="text" name="firstName" value=targetUser.firstName required) + label(for="firstName")=__("firstName") + ":" + div.input-field.col.s6 + input#lastName(type="text" name="lastName" value=targetUser.lastName required) + label(for="lastName")=__("lastName") + ":" + div.row + div.input-field.col.s12 + select(name="department" required=) + each department in departments + option(value=department.name selected=department.name === targetUser.DepartmentName)=department.name + label=__("department") + ":" + div.row + div.input-field.col.s12 + input#password(type="password" name="password") + label(for="password")=__("password") + ":" + div.row + div.input-field.col.s12 + input#permissions(type="number" min="0" max="3" value=targetUser.permissions name="permissions") + label(for="permissions")=__("admin.permissions") + div.row.center + div.input-field.col.s12 + +submit(__("save")) diff --git a/views/admin/users/index.pug b/views/admin/users/index.pug index 3ddf142..48d529a 100644 --- a/views/admin/users/index.pug +++ b/views/admin/users/index.pug @@ -1,18 +1,20 @@ extends ../../layout block content - div.card#usersManagement + div.container h1=__("admin.userManagement") - a.add(href="/admin/users/add") - button=__("admin.add") - div + ul.collection each user in users - div.user - h2=user.username - div.buttons - a.edit(href="/admin/users/edit?name="+user.username) - button=__("admin.edit") - a.remove(href="/admin/users/delete?name="+user.username) - button=__("admin.remove") + li.collection-item + div=user.username + div.secondary-content + a(href="/admin/users/edit?name="+user.username) + i.material-icons edit + a.delete(href="/admin/users/delete?name="+user.username) + i.material-icons remove + + div.fixed-action-btn + a.btn-floating.btn-large.blue(href="/admin/users/add") + i.large.material-icons add script(src="/javascripts/admin/users.js")