From 77514867ed4dc20c39f61b70f91788aa5a740e44 Mon Sep 17 00:00:00 2001 From: flifloo Date: Sun, 27 Sep 2020 17:52:35 +0200 Subject: [PATCH 01/13] Nav bar rework --- public/javascripts/layout.js | 4 ++++ views/layout.pug | 41 +++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/public/javascripts/layout.js b/public/javascripts/layout.js index f2cf417..0e6bc79 100644 --- a/public/javascripts/layout.js +++ b/public/javascripts/layout.js @@ -22,6 +22,10 @@ dark.addEventListener("click", () => { contact.classList.add("hide"); }); +document.addEventListener("DOMContentLoaded", function() { + M.Sidenav.init(document.querySelectorAll(".sidenav")); +}); + function cb(token) { document.querySelectorAll("div.recaptcha.recaptcha-cb").forEach(el => { el.classList.remove("recaptcha-cb"); diff --git a/views/layout.pug b/views/layout.pug index c10bb24..57aa2b3 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -4,29 +4,35 @@ doctype html html head title= title - link(rel="stylesheet", href="/stylesheets/style.css") + link(rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons") + link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css") + link(rel="stylesheet" href="/stylesheets/style.css") + meta(name="viewport" content="width=device-width, initial-scale=1.0") body - block content - - div#user - a(href="/")=__("layout.home") + mixin nav if user if user.permissions >= 1 - p - - a(href="/sandwiches")=__("sandwiches") + li: a(href="/sandwiches")=__("sandwiches") if user.permissions >= 2 - p - - a(href="/orders")=__("orders") + li: a(href="/orders")=__("orders") if user.permissions >= 3 - p - - a(href="/admin")=__("admin.title") - p | - if user - a(href="/profile")=user.username - a(href="/logout")=__("layout.logout") + li: a(href="/admin")=__("admin.title") + li: a(href="/profile")=user.username + li: a(href="/logout")=__("layout.logout") else - a(href="/login")=__("layout.login") - a(href="/register")=__("layout.register") + li: a(href="/login")=__("layout.login") + li: a(href="/register")=__("layout.register") + nav.orange(role="navigation") + div.nav-wrapper.container + a.brand-logo(href="/") SOD + a.sidenav-trigger(href="#" data-target="mobile-nav"): i.material-icons menu + ul.right.hide-on-med-and-down + +nav + ul#mobile-nav.sidenav + +nav + + div.hide + block content div#more a=__("layout.about") @@ -92,6 +98,7 @@ html div.field +submit(value=__("send")) + script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js") script(src="/javascripts/layout.js") if !test p !{captcha} From 351e7426ff0a366e207c391eeb434f1f277acc1e Mon Sep 17 00:00:00 2001 From: flifloo Date: Sun, 27 Sep 2020 20:43:11 +0200 Subject: [PATCH 02/13] Home page rework --- locales/en.json | 4 +- locales/fr.json | 4 +- public/javascripts/index.js | 61 ++++++++++------- public/javascripts/layout.js | 2 +- views/index.pug | 84 ++++++++++++----------- views/layout.pug | 126 +++++++++++++++++------------------ views/mixin.pug | 3 +- 7 files changed, 155 insertions(+), 129 deletions(-) diff --git a/locales/en.json b/locales/en.json index 2889d7c..9367764 100644 --- a/locales/en.json +++ b/locales/en.json @@ -31,7 +31,9 @@ "day": "Day", "pay": "Pay", "payment": "Payment method", - "creditCard": "Credit card" + "creditCard": "Credit card", + "chooseDepartment": "Choose your department", + "chooseSandwich": "Choose your sandwich" }, "login": { "title": "Login", diff --git a/locales/fr.json b/locales/fr.json index 3e19a57..ed404e9 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -31,7 +31,9 @@ "day": "Jour", "pay": "Payer", "payment": "Mode de paiement", - "creditCard": "CB" + "creditCard": "CB", + "chooseDepartment": "Choisissez votre département", + "chooseSandwich": "Choisissez votre sandwiche" }, "login": { "title": "Se connecter", diff --git a/public/javascripts/index.js b/public/javascripts/index.js index fd3ecb6..e393aa4 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -1,37 +1,52 @@ -const orderAction = document.getElementById("order-action"); -const rmButton = document.getElementById("remove-order"); +const orders = document.getElementById("orders"); +const sandwich = document.getElementById("sandwich"); +const day = document.getElementById("day"); const locals = { - order: document.querySelector("#order1>h2").innerHTML.replace(" 1", ""), - sandwich: document.querySelector("label[for='sandwich1']").innerHTML, - day: document.querySelector("label[for='day1']").innerHTML + sandwich: document.querySelector("#oderCreator label").innerHTML, + date: document.querySelector("label[for=day]").innerHTML }; -const [min, max] = [document.getElementById("day1").min, document.getElementById("day1").max]; function lastOrderId() { - let list = document.querySelectorAll("div.order h2"); - return parseInt(list[list.length-1].innerText.replace(locals.order+" ", "")); + if (orders.lastChild) + return parseInt(orders.lastChild.id.replace("order", "")); + return 0; } -document.getElementById("add-order").addEventListener("click", () => { +document.getElementById("addOrder").addEventListener("click", () => { + if (!sandwich.value || !day.value) + return; + let id = lastOrderId() + 1; - orderAction.insertAdjacentHTML("beforebegin", `
-

${locals.order} ${id}

-
+ + //ToDo submit button check + + orders.insertAdjacentHTML("beforeend", `
+
+ -
-
- - +
+ +
+ remove
`); - document.getElementById("order"+lastOrderId()).scrollIntoView({behavior: "smooth"}); - rmButton.classList.remove("hide"); + + sandwich.selectedIndex = 0; + day.value = ""; + + let order = document.getElementById("order"+id); + order.querySelector("a").addEventListener("click", () => { + order.remove(); + if (lastOrderId() === 0) { + sandwich.required = true; + day.required = true; + } + }); + + document.getElementById("order"+id).scrollIntoView({behavior: "smooth"}); }); -rmButton.addEventListener("click", () => { - let id = lastOrderId(); - document.getElementById("order"+id).remove(); - if (id === 2) - rmButton.classList.add("hide"); +document.querySelector("form").addEventListener("submit", () => { + return lastOrderId(); }); diff --git a/public/javascripts/layout.js b/public/javascripts/layout.js index 0e6bc79..7dbd804 100644 --- a/public/javascripts/layout.js +++ b/public/javascripts/layout.js @@ -23,7 +23,7 @@ dark.addEventListener("click", () => { }); document.addEventListener("DOMContentLoaded", function() { - M.Sidenav.init(document.querySelectorAll(".sidenav")); + M.AutoInit(); }); function cb(token) { diff --git a/views/index.pug b/views/index.pug index 57752db..4f1787b 100644 --- a/views/index.pug +++ b/views/index.pug @@ -1,49 +1,55 @@ extends layout block content - div.card - h1= title - p=__("index.welcome") - form#order(action="/order" method="POST") - div.field - label(for="department")=__("department")+":" - +list("department", "department-list", "department", user ? user.DepartmentName : "", "off", true) - datalist#department-list - each department in departments - option(value=department.name) + div.container + h4.center=__("index.welcome") + div.row + form#order.col.s12(action="/order" method="POST") + div.row + div.input-field.col.s12 + select(name="department" required) + option(value="" disabled selected hidden)=__("index.chooseDepartment") + each department in departments + option(value=department.name)=department.name + label=__("department")+":" - div.field - label(for="firstname")=__("firstName")+":" - input#firstname(type="text" name="firstName" value=user ? user.firstName : "" required) - div.field - label(for="lastname")=__("lastName")+":" - input#lastname(type="text" name="lastName" value=user ? user.lastName : "" required) + div.row + div.input-field.col.s6 + input#firstname(type="text" name="firstName" value=user ? user.firstName : "" required) + label(for="firstname")=__("firstName")+":" + div.input-field.col.s6 + input#lastname(type="text" name="lastName" value=user ? user.lastName : "" required) + label(for="lastname")=__("lastName")+":" - div#order1.order - h2=__("order")+" 1" - div.field - label(for="sandwich1")=__("sandwich")+":" - +list("sandwich1", "sandwich-list", "sandwiches[1]", "", "off", true) - div.field - label(for="day1")=__("index.day")+":" - input#day1(type="date" min=date.firstDate ? date.firstDate : "" max=date.lastDate ? date.lastDate : "" name="dates[1]" required) + div#oderCreator.row + h5=__("order") + div.input-field.col.s6 + select#sandwich + option(value="" disabled selected hidden)=__("index.chooseSandwich") + each sandwich in sandwiches + option(value=sandwich.name)=sandwich.name + label=__("sandwich")+":" + div.input-field.col.s6 + input#day(type="date" min=date.firstDate ? date.firstDate : "" max=date.lastDate ? date.lastDate : "") + label(for="day")=__("index.day")+":" + a#addOrder.btn-floating.btn-large.waves-effect.waves-light.blue: i.material-icons add - div#order-action - a#add-order + - a#remove-order.hide - + div#orders - h3=__("index.payment") - div.field.buttons - label(for="lyf_pay") LyfPay - input#lyf_pay(type="radio" name="payment" value="lyfPay" checked) - label(for="credit_card")=__("index.creditCard") - input#credit_card(type="radio" name="payment" value="creditCard") + div.row + h5=__("index.payment") + div.col.s12 + p + label + input(type="radio" name="payment" value="lyfPay" checked) + span LyfPay + p + label + input(type="radio" name="payment" value="creditCard") + span=__("index.creditCard") - div.field - +submit(value=__("index.pay")) - - datalist#sandwich-list - each sandwich in sandwiches - option(value=sandwich.name) + div.row.center + div.input-field.col.s12 + +submit(__("index.pay")) script(src="/javascripts/index.js") diff --git a/views/layout.pug b/views/layout.pug index 57aa2b3..912f7cd 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -6,7 +6,7 @@ html title= title link(rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons") link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css") - link(rel="stylesheet" href="/stylesheets/style.css") + //link(rel="stylesheet" href="/stylesheets/style.css") meta(name="viewport" content="width=device-width, initial-scale=1.0") body mixin nav @@ -31,72 +31,72 @@ html ul#mobile-nav.sidenav +nav - div.hide - block content + block content - div#more - a=__("layout.about") - a=__("contact") + .hide + div#more + a=__("layout.about") + a=__("contact") - div#dark.hide - div#about.popup.card.hide - h1=__("layout.about") - p=__("layout.aboutDescription") - div.images - div - img(src="/images/logoBio.png") - p=__("layout.bio") - div - img(src="/images/logoChimie.png") - p=__("layout.chemistry") - div - img(src="/images/logoGC.png") - p=__("layout.GC") - div - img(src="/images/logoGCGP.png") - p=__("layout.GCPD") - div - img(src="/images/logoGEA.png") - p=__("layout.GEA") - div - img(src="/images/logoInfo.png") - p=__("layout.IT") - p.before-link=__("layout.made") - a(href="https://www.linkedin.com/in/florian-charlaix" target="_blank") Florian Charlaix - p.before-link=__("layout.powered") - a(href="https://sapinet.fr" target="_blank") Sapinet - div#contact.popup.card.hide - h1=__("contact") - form(action="/contact" method="POST") - div.cont + div#dark.hide + div#about.popup.card.hide + h1=__("layout.about") + p=__("layout.aboutDescription") + div.images + div + img(src="/images/logoBio.png") + p=__("layout.bio") + div + img(src="/images/logoChimie.png") + p=__("layout.chemistry") + div + img(src="/images/logoGC.png") + p=__("layout.GC") + div + img(src="/images/logoGCGP.png") + p=__("layout.GCPD") + div + img(src="/images/logoGEA.png") + p=__("layout.GEA") + div + img(src="/images/logoInfo.png") + p=__("layout.IT") + p.before-link=__("layout.made") + a(href="https://www.linkedin.com/in/florian-charlaix" target="_blank") Florian Charlaix + p.before-link=__("layout.powered") + a(href="https://sapinet.fr" target="_blank") Sapinet + div#contact.popup.card.hide + h1=__("contact") + form(action="/contact" method="POST") + div.cont + div.field + label(for="firstNameContact")="* "+__("firstName") + input#firstNameContact(type="text" name="firstName" value=user?user.firstName:"" required) + div.field + label(for="lastNameContact")="* "+__("lastName") + input#lastNameContact(type="text" name="lastName" value=user ? user.lastName : "" required) + div.cont + div.field + label(for="emailContact")="* "+__("email") + input#emailContact(type="email" name="email" value=user ? user.email : "" required) + div.field + label(for="phoneNumberContact")=__("layout.phoneNumber") + input#phoneNumberContact(type="tel" name="phoneNumber") div.field - label(for="firstNameContact")="* "+__("firstName") - input#firstNameContact(type="text" name="firstName" value=user?user.firstName:"" required) + label(for="subjectContact")="* "+__("layout.subject") + +list("subjectContact", "subjectContactList", "subject", "", "off", true) + datalist#subjectContactList + option(value=__("layout.commandEdit")) + option(value=__("layout.commandRemove")) + option(value=__("layout.question")) + option(value=__("layout.profile")) + option(value=__("layout.other")) + p=__("layout.warnMessage") + div.field.message + label(for="messageContact")=__("layout.message") + textarea#messageContact(name="message" required) div.field - label(for="lastNameContact")="* "+__("lastName") - input#lastNameContact(type="text" name="lastName" value=user ? user.lastName : "" required) - div.cont - div.field - label(for="emailContact")="* "+__("email") - input#emailContact(type="email" name="email" value=user ? user.email : "" required) - div.field - label(for="phoneNumberContact")=__("layout.phoneNumber") - input#phoneNumberContact(type="tel" name="phoneNumber") - div.field - label(for="subjectContact")="* "+__("layout.subject") - +list("subjectContact", "subjectContactList", "subject", "", "off", true) - datalist#subjectContactList - option(value=__("layout.commandEdit")) - option(value=__("layout.commandRemove")) - option(value=__("layout.question")) - option(value=__("layout.profile")) - option(value=__("layout.other")) - p=__("layout.warnMessage") - div.field.message - label(for="messageContact")=__("layout.message") - textarea#messageContact(name="message" required) - div.field - +submit(value=__("send")) + +submit(value=__("send")) script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js") script(src="/javascripts/layout.js") diff --git a/views/mixin.pug b/views/mixin.pug index 2fa7ff4..a8af50a 100644 --- a/views/mixin.pug +++ b/views/mixin.pug @@ -1,6 +1,7 @@ mixin submit(value) div.recaptcha.recaptcha-cb - input(type="submit" value!=value) + button.btn.waves-effect.waves-light(type="submit" name="action")=value + i.material-icons.right send mixin list(id, list, name, value="", autocomplete="on", required=false) span.list_arrow From 0fa915dc917a63685178b20f7bd2836eec221e02 Mon Sep 17 00:00:00 2001 From: flifloo Date: Sun, 27 Sep 2020 20:58:21 +0200 Subject: [PATCH 03/13] Login, register & forget rework --- locales/en.json | 4 ++-- locales/fr.json | 4 ++-- views/forget.pug | 40 ++++++++++++++++++-------------- views/index.pug | 2 +- views/login.pug | 32 ++++++++++++++----------- views/register.pug | 58 +++++++++++++++++++++++++--------------------- 6 files changed, 78 insertions(+), 62 deletions(-) diff --git a/locales/en.json b/locales/en.json index 9367764..3eb3839 100644 --- a/locales/en.json +++ b/locales/en.json @@ -32,7 +32,6 @@ "pay": "Pay", "payment": "Payment method", "creditCard": "Credit card", - "chooseDepartment": "Choose your department", "chooseSandwich": "Choose your sandwich" }, "login": { @@ -94,5 +93,6 @@ "sandwich": "Sandwich", "contact": "Contact", "messageSend": "The message has been sent", - "forgetPassword": "Forgot your password" + "forgetPassword": "Forgot your password", + "chooseDepartment": "Choose your department" } diff --git a/locales/fr.json b/locales/fr.json index ed404e9..e3690bc 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -32,7 +32,6 @@ "pay": "Payer", "payment": "Mode de paiement", "creditCard": "CB", - "chooseDepartment": "Choisissez votre département", "chooseSandwich": "Choisissez votre sandwiche" }, "login": { @@ -95,5 +94,6 @@ "contact": "Contact", "messageSend": "Le message a bien été envoyé", "forgetPassword": "Mot de passe oublié", - "send": "send" + "send": "send", + "chooseDepartment": "Choisissez votre département" } \ No newline at end of file diff --git a/views/forget.pug b/views/forget.pug index 332068d..f034ba8 100644 --- a/views/forget.pug +++ b/views/forget.pug @@ -1,20 +1,26 @@ extends layout block content - div.card - h1=__("forgetPassword") - if (!token) - form(action="/forget" method="POST") - div.field - label(for="email")=__("email") - input#email(type="email" name="email" required) - div.field - +submit(value=__("send")) - else - form(action="/forget" method="POST") - input(type="hidden" name="token" value=token) - div.field - label(for="password")=__("password") - input#password(type="password" name="password" required) - div.field - +submit(value=__("send")) + div.container + div.row + h3=__("forgetPassword") + if (!token) + form(action="/forget" method="POST") + div.row + div.input-field.col.s12 + input#email(type="email" name="email" required) + label(for="email")=__("email") + div.row + div.input-field.col.s12 + +submit(__("send")) + else + form(action="/forget" method="POST") + div.row + input(type="hidden" name="token" value=token) + 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 + +submit(__("send")) diff --git a/views/index.pug b/views/index.pug index 4f1787b..0a1c968 100644 --- a/views/index.pug +++ b/views/index.pug @@ -8,7 +8,7 @@ block content div.row div.input-field.col.s12 select(name="department" required) - option(value="" disabled selected hidden)=__("index.chooseDepartment") + option(value="" disabled selected hidden)=__("chooseDepartment") each department in departments option(value=department.name)=department.name label=__("department")+":" diff --git a/views/login.pug b/views/login.pug index 8867af1..897a555 100644 --- a/views/login.pug +++ b/views/login.pug @@ -1,18 +1,22 @@ extends layout block content - div.card - form(action="/login" method="POST") - h1=__("login.title") - div.field - label(for="username")=__("username")+":" - input#username(type="text" name="username" required) - div.field - label(for="password")=__("password")+":" - input#password(type="password" name="password" required) - div.field - +submit(value=__("login.submit")) + div.container + div.row + form(action="/login" method="POST") + h3=__("login.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#password(type="password" name="password" required) + label(for="password")=__("password")+":" + div.row.center + div.input-field.col.s12 + +submit(__("login.submit")) - div.field - a(href="/forget") - input(type="button" value=__("forgetPassword")) + div.row.center + div.input-field.col.s12 + a.btn.waves-effect.waves-light.red(href="/forget")=__("forgetPassword") diff --git a/views/register.pug b/views/register.pug index 9a0414c..a980d81 100644 --- a/views/register.pug +++ b/views/register.pug @@ -1,29 +1,35 @@ extends layout block content - form.card(action="/register" 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 - +submit(value=__("register.submit")) - - datalist#department-list - each department in departments - option(value=department.name) + div.container + div.row + form(action="/register" method="POST") + h3=__("register.title") + div.row + div.input-field.col.s6 + input#username(type="text" name="username" required) + label(for="username")=__("username")+":" + div.input-field.col.s6 + 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.center + div.input-field.col.s12 + +submit(__("register.submit")) From 80187cf71f30345926e7e5709c79ce24b8174f4b Mon Sep 17 00:00:00 2001 From: flifloo Date: Sun, 27 Sep 2020 21:38:04 +0200 Subject: [PATCH 04/13] Profile rework --- views/index.pug | 2 +- views/profile.pug | 85 +++++++++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/views/index.pug b/views/index.pug index 0a1c968..ffb78c2 100644 --- a/views/index.pug +++ b/views/index.pug @@ -10,7 +10,7 @@ block content select(name="department" required) option(value="" disabled selected hidden)=__("chooseDepartment") each department in departments - option(value=department.name)=department.name + option(value=department.name selected=user && user.DepartmentName===department.name)=department.name label=__("department")+":" div.row diff --git a/views/profile.pug b/views/profile.pug index 4dde51b..fbf720b 100644 --- a/views/profile.pug +++ b/views/profile.pug @@ -1,44 +1,51 @@ extends layout block content - div.card - h1=__("profile.title") - form(action="/profile" method="POST") - h2=__("profile.infos") - div.field - label(for="username")=__("username")+":" - input#username(type="text" name="username" value=user.username disabled required) - div.field - label(for="email")=__("email")+":" - input#email(type="email" name="email" value=user.email required) - div.field - label(for="firstName")=__("firstName")+":" - input#firstName(type="text" name="firstName" value=user.firstName required) - div.field - label(for="lastName")=__("lastName")+":" - input#lastName(type="text" name="lastName" value=user.lastName required) - div.field - label(for="department")=__("department")+":" - +list("department", "department-list", "department", user.DepartmentName, "off", true) - div.field - label(for="password")=__("password")+":" - input#password(type="password" name="password") - div.field - input(type="submit" value=__("save")) + div.container + div.row + h4=__("profile.title") + form(action="/profile" method="POST") + h2=__("profile.infos") + div.row + div.input-field.col.s6 + input#username(type="text" name="username" value=user.username disabled required) + label(for="username")=__("username")+":" + div.input-field.col.s6 + input#email(type="email" name="email" value=user.email required) + label(for="email")=__("email")+":" + div.row + div.input-field.col.s6 + input#firstName(type="text" name="firstName" value=user.firstName required) + label(for="firstName")=__("firstName")+":" + div.input-field.col.s6 + input#lastName(type="text" name="lastName" value=user.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===user.DepartmentName)=department.name + label=__("department")+":" + div.row + div.input-field.col.s12 + label(for="password")=__("password")+":" + input#password(type="password" name="password") + div.row.center + div.input-field.col.s12 + +submit(__("save")) - datalist#department-list - each department in departments - option(value=department.name) + if (!user.emailVerified) + div.row.center + div.input-field.col.s12 + a.btn.waves-effect.waves-light.yellow.darken-4(href="/profile/resend")=__("profile.emailCheck") - if (!user.emailVerified) - div.field - a(href="/profile/resend") - input(type="button" value=__("profile.emailCheck")) - - div.card#userOrderList - h1=__("orders") - each order in orders - div - h2=order.id - each sandwich in order.Sandwiches - p #{sandwich.name} - #{sandwich.SandwichOrder.date} + div.container.valign-wrapper + div.row.center + h4=__("orders") + each order in orders + div.col + div.card.blue-grey + div.card-content.white-text + span.card-title=order.id + each sandwich in order.Sandwiches + p #{sandwich.name} - #{sandwich.SandwichOrder.date} From 498a2fa977aa997214227c8790361a8025c31cb2 Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 28 Sep 2020 15:08:58 +0200 Subject: [PATCH 05/13] sandwiches & orders rework --- public/javascripts/orders.js | 18 +++++------------- routes/orders.js | 6 +++--- views/orders.pug | 27 ++++++++++++--------------- views/sandwiches.pug | 12 +++++++----- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/public/javascripts/orders.js b/public/javascripts/orders.js index cc92cb2..aa83013 100644 --- a/public/javascripts/orders.js +++ b/public/javascripts/orders.js @@ -1,25 +1,17 @@ const date = document.getElementById("date"); - -function collapse(e, subDiv) { +document.querySelectorAll("h4").forEach((e) => { e.addEventListener("click", ev => { ev.stopPropagation(); let action; - if (e.classList.contains("collapse")) + if (e.classList.contains("collapsed")) action = "remove"; else action = "add"; - e.querySelectorAll("."+subDiv).forEach(e => e.classList[action]("hide")); - e.classList[action]("collapse"); + e.parentElement.querySelectorAll(".collection").forEach(c => c.classList[action]("hide")); + e.classList[action]("collapsed"); }) -} - - -document.querySelectorAll(".department").forEach(e => collapse(e, "user")); - -document.querySelectorAll(".user").forEach(e => collapse(e, "order")); - -document.querySelectorAll(".order").forEach(e => collapse(e, "sandwich")); +}); date.addEventListener("change", () => window.location.href = "?date="+date.value); diff --git a/routes/orders.js b/routes/orders.js index e56f90d..b0d95f7 100644 --- a/routes/orders.js +++ b/routes/orders.js @@ -30,11 +30,11 @@ router.get("/", sessionCheck(2), async (req, res) => { orders[o.DepartmentName][name][o.id] = o.Sandwiches; } res.render("orders", {title: "SOD - Orders", orders: orders, date: date}); -}).post("/give", sessionCheck(2), async (req, res) => { - if (!req.body.id) +}).get("/give", sessionCheck(2), async (req, res) => { + if (!req.query.id) return error(req, res, "Missing arg !", 400); - let order = await models.SandwichOrder.findByPk(req.body.id, {where: {give: false}}); + let order = await models.SandwichOrder.findByPk(req.query.id, {where: {give: false}}); if (!order) return error(req, res, "Invalid order id !", 400); diff --git a/views/orders.pug b/views/orders.pug index 8581691..82c0b1a 100644 --- a/views/orders.pug +++ b/views/orders.pug @@ -1,25 +1,22 @@ extends layout block content - div#date-selector.card + div.container label(for="date")=__("date") input#date(type="date" value=date) - div#orders.card + div.container h1=__("orders") each user, department in orders - div.department - h2= department + div.container + h4=department each orders, name in user - div.user - h3= name - each order, id in orders - div.order - h4 #{__("order")} N°#{id} - each sandwich in order - div.sandwich - form.give(method="POST" action="/orders/give") - input(type="hidden" name="id" value=sandwich.SandwichOrder.id) - input.give(type="submit" value="v") - h4= sandwich.name + each order, id in orders + ul.collection.with-header + li.collection-header: h5 #{name} - #{__("order")} N°#{id} + each sandwich in order + li.collection-item + div=sandwich.name + a.secondary-content(href="/orders/give?id="+sandwich.SandwichOrder.id) + i.material-icons check script(src="/javascripts/orders.js") diff --git a/views/sandwiches.pug b/views/sandwiches.pug index 356e561..4010ee7 100644 --- a/views/sandwiches.pug +++ b/views/sandwiches.pug @@ -1,13 +1,15 @@ extends layout block content - div#date-selector.card + div.container label(for="date")=__("date") input#date(type="date" value=date) - div.card + div.container h1=__("sandwiches") - each sandwich in sandwiches - div.sandwich - h2 #{sandwich.name}: #{sandwich.dataValues.number} + ul.collection + each sandwich in sandwiches + li.collection-item + div=sandwich.name + a.secondary-content=sandwich.dataValues.number script(src="/javascripts/sandwiches.js") From efb723464185563b14d21127215395d7b7bcbf30 Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 28 Sep 2020 15:10:36 +0200 Subject: [PATCH 06/13] Little fix on index day label --- public/javascripts/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/index.js b/public/javascripts/index.js index e393aa4..0211d55 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -3,7 +3,7 @@ const sandwich = document.getElementById("sandwich"); const day = document.getElementById("day"); const locals = { sandwich: document.querySelector("#oderCreator label").innerHTML, - date: document.querySelector("label[for=day]").innerHTML + day: document.querySelector("label[for=day]").innerText }; function lastOrderId() { From cd6d224940c3ed7b5d5e876101bcb3c2c2290b8b Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 28 Sep 2020 22:35:00 +0200 Subject: [PATCH 07/13] Admin index rework --- views/admin/index.pug | 58 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/views/admin/index.pug b/views/admin/index.pug index 5afa682..3de9b54 100644 --- a/views/admin/index.pug +++ b/views/admin/index.pug @@ -1,30 +1,36 @@ extends ../layout block content - div.card - h1=__("admin.title") - div - h2=__("admin.ordersManagement") - div.buttons - a(href="/admin/orders/date") - button=__("admin.ordersDate") - a(href="/admin/orders") - button=__("admin.manageOrders") + div.container + h4=__("admin.title") + div.row.center + div.col + div.card.blue-grey + div.card-content.white-text + span.card-title=__("admin.ordersManagement") + p + div.card-action + a(href="/admin/orders/date")=__("admin.ordersDate") + a(href="/admin/orders")=__("admin.manageOrders") - div - h2=__("admin.sandwichManagement") - div.buttons - a(href="/admin/sandwiches") - button=__("admin.manageSandwiches") - - div - h2=__("admin.departmentsManagement") - div.buttons - a(href="/admin/departments") - button=__("admin.manageDepartments") - - div - h2=__("admin.userManagement") - div.buttons - a(href="/admin/users") - button=__("admin.manageUsers") + div.col + div.card.blue-grey + div.card-content.white-text + span.card-title=__("admin.sandwichManagement") + p + div.card-action + a(href="/admin/sandwiches")=__("admin.manageSandwiches") + div.col + div.card.blue-grey + div.card-content.white-text + span.card-title=__("admin.departmentsManagement") + p + div.card-action + a(href="/admin/departments")=__("admin.manageDepartments") + div.col + div.card.blue-grey + div.card-content.white-text + span.card-title=__("admin.userManagement") + p + div.card-action + a(href="/admin/users")=__("admin.manageUsers") From 84cd60e52c76ab83f5d4a3673766f6e9777a436a Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 28 Sep 2020 22:55:35 +0200 Subject: [PATCH 08/13] Orders management rework --- locales/en.json | 3 +- locales/fr.json | 3 +- public/javascripts/admin/orders/add.js | 69 +++++++++----- public/javascripts/admin/orders/edit.js | 3 + public/javascripts/admin/orders/index.js | 3 +- public/javascripts/index.js | 2 - views/admin/orders/add.pug | 91 +++++++++--------- views/admin/orders/date.pug | 23 +++-- views/admin/orders/edit.pug | 114 +++++++++++++---------- views/admin/orders/index.pug | 30 +++--- 10 files changed, 190 insertions(+), 151 deletions(-) create mode 100644 public/javascripts/admin/orders/edit.js diff --git a/locales/en.json b/locales/en.json index 3eb3839..dc3b259 100644 --- a/locales/en.json +++ b/locales/en.json @@ -71,7 +71,8 @@ "firstDate": "First date", "lastDate": "Last date", "paid": "Paid", - "given": "Given" + "given": "Given", + "chooseUser": "Choose an user" }, "payment": { "successful": "Payment successful !", diff --git a/locales/fr.json b/locales/fr.json index e3690bc..04b7836 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -71,7 +71,8 @@ "firstDate": "Première date", "lastDate": "Dernière date", "paid": "Payé", - "given": "Donné" + "given": "Donné", + "chooseUser": "Choisissez un utilisateur" }, "payment": { "successful": "Paiement réussi !", diff --git a/public/javascripts/admin/orders/add.js b/public/javascripts/admin/orders/add.js index 7955e1d..62337de 100644 --- a/public/javascripts/admin/orders/add.js +++ b/public/javascripts/admin/orders/add.js @@ -1,40 +1,59 @@ -const orderAction = document.getElementById("order-action"); -const rmButton = document.getElementById("remove-order"); +const orders = document.getElementById("orders"); +const sandwich = document.getElementById("sandwich"); +const day = document.getElementById("day"); const locals = { - order: document.querySelector("#order1>h2").innerHTML.replace(" 1", ""), - sandwich: document.querySelector("label[for='sandwich1']").innerHTML, - day: document.querySelector("label[for='day1']").innerHTML + sandwich: document.querySelector("#oderCreator label").innerHTML, + day: document.querySelector("label[for=day]").innerText, + give: document.querySelector("p label span").innerText }; function lastOrderId() { - let list = document.querySelectorAll("div.order h2"); - return parseInt(list[list.length-1].innerText.replace(locals.order+" ", "")); + if (orders.lastChild) + return parseInt(orders.lastChild.id.replace("order", "")); + return 0; } -document.getElementById("add-order").addEventListener("click", () => { +document.getElementById("addOrder").addEventListener("click", () => { + if (!sandwich.value || !day.value) + return; + let id = lastOrderId() + 1; - orderAction.insertAdjacentHTML("beforebegin", `
-

${locals.order} ${id}

-
+ + orders.insertAdjacentHTML("beforeend", `
+
+ -
-
- - +
+ +
-
- - +
+

+ +

+ remove
`); - document.getElementById("order"+lastOrderId()).scrollIntoView({behavior: "smooth"}); - rmButton.classList.remove("hide"); + + sandwich.selectedIndex = 0; + day.value = ""; + + let order = document.getElementById("order"+id); + order.querySelector("a").addEventListener("click", () => { + order.remove(); + if (lastOrderId() === 0) { + sandwich.required = true; + day.required = true; + } + }); + + document.getElementById("order"+id).scrollIntoView({behavior: "smooth"}); }); -rmButton.addEventListener("click", () => { - let id = lastOrderId(); - document.getElementById("order"+id).remove(); - if (id === 2) - rmButton.classList.add("hide"); +document.querySelector("form").addEventListener("submit", () => { + return lastOrderId(); }); diff --git a/public/javascripts/admin/orders/edit.js b/public/javascripts/admin/orders/edit.js new file mode 100644 index 0000000..1e2f9ce --- /dev/null +++ b/public/javascripts/admin/orders/edit.js @@ -0,0 +1,3 @@ +for (let e of document.getElementById("orders").children) { + e.querySelector("a").addEventListener("click", () => e.remove()); +} diff --git a/public/javascripts/admin/orders/index.js b/public/javascripts/admin/orders/index.js index eeb95e1..814efa7 100644 --- a/public/javascripts/admin/orders/index.js +++ b/public/javascripts/admin/orders/index.js @@ -1,5 +1,4 @@ -document.querySelectorAll(".order form") - .forEach(e => e.addEventListener("submit", ev => { +document.querySelectorAll(".delete").forEach(e => e.addEventListener("click", ev => { if (!confirm("Do you really want to remove this ?")) ev.preventDefault(); })); diff --git a/public/javascripts/index.js b/public/javascripts/index.js index 0211d55..047b3e4 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -18,8 +18,6 @@ document.getElementById("addOrder").addEventListener("click", () => { let id = lastOrderId() + 1; - //ToDo submit button check - orders.insertAdjacentHTML("beforeend", `
diff --git a/views/admin/orders/add.pug b/views/admin/orders/add.pug index 314affc..85aab6b 100644 --- a/views/admin/orders/add.pug +++ b/views/admin/orders/add.pug @@ -1,56 +1,59 @@ extends ../../layout block content - div.card + span#dummy.hide=__("admin.given") + div.container h1=__("admin.ordersManagement") - form#order(method="POST") - div.field - label(for="department")=__("department") + ":" - +list("department", "department-list", "department", "", "off", true) - datalist#department-list - each department in departments - option(value=department.name) + div.row + form#order.col.s12(method="POST") + 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.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.row + div.input-field.col.s12 + select(name="username") + option(value="" disabled selected hidden)=__("admin.chooseUser") + each user in users + option(value=user.username)=user.username + label=__("username") + ":" - div.field - label(for="username")=__("username") - +list("username", "usernames", "username", "", "off") + 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#order1.order - h2=__("order") + " 1" - div.field - label(for="sandwich1")=__("sandwich") + ":" - +list("sandwich1", "sandwich-list", "sandwiches[1]", "", "off", true) - div.field - label(for="day1")=__("index.day") + ":" - input#day1(type="date" name="dates[1]" required) - div.field - label(for="given1")=__("admin.given") - input#given1(type="checkbox" name="give[1]") + div#oderCreator.row + h5=__("order") + div.input-field.col.s6 + select#sandwich + option(value="" disabled selected hidden)=__("index.chooseSandwich") + each sandwich in sandwiches + option(value=sandwich.name)=sandwich.name + label=__("sandwich") + ":" + div.input-field.col.s6 + input#day(type="date") + label(for="day")=__("index.day") + ":" + a#addOrder.btn-floating.btn-large.waves-effect.waves-light.blue: i.material-icons add - div#order-action - a#add-order + - a#remove-order.hide - + div#orders - div.field - label(for="paid")=__("admin.paid") - input#paid(type="checkbox" name="paid") - - div.field - input#send(type="submit" value=__("admin.add")) - - datalist#sandwich-list - each sandwich in sandwiches - option(value=sandwich.name) - datalist#usernames - each user in users - option(value=user.username) + div.row.center + div.input-field.col.s12 + p + label(for="paid") + input#paid(type="checkbox" name="paid") + span=__("admin.paid") + div.row.center + div.input-field.col.s12 + +submit(__("admin.add")) script(src="/javascripts/admin/orders/add.js") diff --git a/views/admin/orders/date.pug b/views/admin/orders/date.pug index 9b9b45f..c7f0304 100644 --- a/views/admin/orders/date.pug +++ b/views/admin/orders/date.pug @@ -1,14 +1,17 @@ extends ../../layout block content - div.card#ordersManagement + div.container h1=__("admin.ordersDate") - form(action="/admin/orders/date" method="POST") - div.field - label(for="firstDate")=__("admin.firstDate") - input#firstDate(type="date" name="firstDate" value=date? date.firstDate: "" required) - div.field - label(for="lastDate")=__("admin.lastDate") - input#lastDate(type="date" name="lastDate" value=date? date.lastDate: "" required) - div.field - input(type="submit" value=__("save")) + div.row + form(action="/admin/orders/date" method="POST") + div.row + div.input-field.col.s6 + label(for="firstDate")=__("admin.firstDate") + input#firstDate(type="date" name="firstDate" value=date? date.firstDate: "" required) + div.input-field.col.s6 + label(for="lastDate")=__("admin.lastDate") + input#lastDate(type="date" name="lastDate" value=date? date.lastDate: "" required) + div.row + div.input-field.col.s12 + +submit(__("save")) diff --git a/views/admin/orders/edit.pug b/views/admin/orders/edit.pug index 33a45b2..ced9729 100644 --- a/views/admin/orders/edit.pug +++ b/views/admin/orders/edit.pug @@ -1,63 +1,75 @@ extends ../../layout block content - div.card + div.container h1=__("admin.ordersManagement") - form#order(method="POST") - input(type="hidden" name="id" value=order.id) - div.field - label(for="department")=__("department") + ":" - +list("department", "department-list", "department", order.Department.name, "off", true) - datalist#department-list - each department in departments - option(value=department.name) + div.row + form#order.col.s12(method="POST") + input(type="hidden" name="id" value=order.id) + div.row + div.input-field.col.s12 + select(name="department" required) + each department in departments + option(value=department.name selected=order.Department.name === department.name)=department.name + label=__("department") + ":" - div.field - label(for="firstname")=__("firstName") + ":" - input#firstname(type="text" name="firstName" value=order.firstName required) - div.field - label(for="lastname")=__("lastName") + ":" - input#lastname(type="text" name="lastName" value=order.lastName required) + div.row + div.input-field.col.s12 + select(name="username") + each user in users + option(value=user.username selected=order.User && order.User.username === user.username)=user.username + label=__("username") + ":" - div.field - label(for="username")=__("username") - +list("username", "usernames", "username", order.User ? order.User.username : "", "off") + div.row + div.input-field.col.s6 + input#firstname(type="text" name="firstName" value=order.firstName required) + label(for="firstname")=__("firstName") + ":" + div.input-field.col.s6 + input#lastname(type="text" name="lastName" value=order.lastName required) + label(for="lastname")=__("lastName") + ":" - - i = 0; - each sandwich in order.Sandwiches - - i++; - div.order(id="order"+i) - h2=__("order") + " " + i - div.field - label(for="sandwich"+i)=__("sandwich") + ":" - +list("#sandwich"+i, "sandwich-list", "sandwiches["+i+"]", sandwich.name, "off", true) - div.field - label(for="day"+i)=__("index.day") + ":" - input(id="#day"+i type="date" name="dates["+i+"]" value=sandwich.SandwichOrder.date required) - div.field - label(for="given"+i)=__("admin.given") - input(id="given"+i type="checkbox" name="give["+i+"]" checked=sandwich.SandwichOrder.give) + div#oderCreator.row + h5=__("order") + div.input-field.col.s6 + select#sandwich + option(value="" disabled selected hidden)=__("index.chooseSandwich") + each sandwich in sandwiches + option(value=sandwich.name)=sandwich.name + label=__("sandwich") + ":" + div.input-field.col.s6 + input#day(type="date") + label(for="day")=__("index.day") + ":" + a#addOrder.btn-floating.btn-large.waves-effect.waves-light.blue: i.material-icons add - div#order-action - a#add-order + - if i > 1 - a#remove-order - - else - a#remove-order.hide - + div#orders + - i = 0; + each sandwich in order.Sandwiches + - i++; + div.row(id="order"+i) + div.input-field.col.s6 + input(id="sandwich"+i type="text" name="sandwiches[#{i}]" value=sandwich.name readonly required) + label(for="sandwich"+i)=__("sandwich") + div.input-field.col.s6 + input(id="date"+i type="date" name="dates[#{i}]" value=sandwich.SandwichOrder.date readonly required) + label(for="date"+i)=__("index.day") + div.input-field.col.s12.center + p + label + input(type="checkbox" name="give[#{i}]" checked=sandwich.SandwichOrder.give) + span=__("admin.given") + a.btn-floating.btn-large.waves-effect.waves-light.red + i.material-icons remove - div.field - label(for="paid")=__("admin.paid") - input#paid(type="checkbox" name="paid" checked=order.paid) - - div.field - input#send(type="submit" value=__("save")) - - datalist#sandwich-list - each sandwich in sandwiches - option(value=sandwich.name) - datalist#usernames - each user in users - option(value=user.username) + div.row.center + div.input-field.col.s12 + p + label(for="paid") + input#paid(type="checkbox" name="paid" checked=order.paid) + span=__("admin.paid") + div.row.center + div.input-field.col.s12 + +submit(__("save")) script(src="/javascripts/admin/orders/add.js") + script(src="/javascripts/admin/orders/edit.js") diff --git a/views/admin/orders/index.pug b/views/admin/orders/index.pug index 2fa516c..8adc1d6 100644 --- a/views/admin/orders/index.pug +++ b/views/admin/orders/index.pug @@ -1,23 +1,23 @@ extends ../../layout block content - div.card#ordersManagement + div.container h1=__("admin.ordersManagement") - a.add(href="/admin/orders/add") - button=__("admin.add") - div + ul.collection each order in orders - div.order - div.title - h2=order.id - h3 #{order.firstName} #{order.lastName} - #{order.price}€ - each sandwich in order.Sandwiches - div.sandwich + li.collection-item + div #{order.id} | #{order.firstName} #{order.lastName} - #{order.price}€ + div.secondary-content + a(href="/admin/orders/edit?id=" + order.id) + i.material-icons edit + a.delete(href="/admin/orders/delete?id=" + order.id) + i.material-icons remove + each sandwich in order.Sandwiches p #{sandwich.name} - #{sandwich.SandwichOrder.date} - div.buttons - a.edit(href="/admin/orders/edit?id=" + order.id) - button=__("admin.edit") - a.remove(href="/admin/orders/delete?id=" + order.id) - button=__("admin.remove") + + + div.fixed-action-btn + a.btn-floating.btn-large.blue(href="/admin/orders/add") + i.large.material-icons add script(src="/javascripts/admin/orders/index.js") From 1c0b8100229e044b511affdc57fe77d971b4ef50 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 14:39:13 +0200 Subject: [PATCH 09/13] Sandwiches management rework --- public/javascripts/admin/sandwiches.js | 2 +- views/admin/sandwiches/add.pug | 24 ++++++++++++++---------- views/admin/sandwiches/edit.pug | 26 +++++++++++++++----------- views/admin/sandwiches/index.pug | 24 +++++++++++++----------- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/public/javascripts/admin/sandwiches.js b/public/javascripts/admin/sandwiches.js index 097c76e..09310e5 100644 --- a/public/javascripts/admin/sandwiches.js +++ b/public/javascripts/admin/sandwiches.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 sandwich ?")) ev.preventDefault(); diff --git a/views/admin/sandwiches/add.pug b/views/admin/sandwiches/add.pug index 226f746..1413344 100644 --- a/views/admin/sandwiches/add.pug +++ b/views/admin/sandwiches/add.pug @@ -1,14 +1,18 @@ extends ../../layout block content - div.card#sandwichesManagement + div.container h1=__("admin.new")+" "+__("sandwich") - form(action="/admin/sandwiches/add" method="POST") - div.field - label(for="name")=__("admin.name")+":" - input#name(type="text" name="name" required) - div.field - label(for="price")=__("admin.price") + ":" - input#price(type="number" min="0" step="any" name="price" value="0" required) - div.field - input(type="submit" value=__("admin.add")) + div.row + form(action="/admin/sandwiches/add" method="POST") + div.row + div.input-field.col.s12 + label(for="name")=__("admin.name")+":" + input#name(type="text" name="name" required) + div.row + div.input-field.col.s12 + label(for="price")=__("admin.price") + ":" + input#price(type="number" min="0" step="any" name="price" value="0" required) + div.row.center + div.input-field.col.s12 + +submit(__("admin.add")) diff --git a/views/admin/sandwiches/edit.pug b/views/admin/sandwiches/edit.pug index c71b324..be9709f 100644 --- a/views/admin/sandwiches/edit.pug +++ b/views/admin/sandwiches/edit.pug @@ -1,15 +1,19 @@ extends ../../layout block content - div.card#sandwichesManagement + div.container h1=__("admin.edit")+" "+sandwich.name - form(action="/admin/sandwiches/edit" method="POST") - input.hide(type="text" name="name" value=sandwich.name required) - div.field - label(for="name")=__("admin.name")+":" - input#name(type="text" name="newName" value=sandwich.name required) - div.field - label(for="price")=__("admin.price") + ":" - input#price(type="number" min="0" step="any" name="price" value=sandwich.price required) - div.field - input(type="submit" value=__("save")) + div.row + form(action="/admin/sandwiches/edit" method="POST") + input.hide(type="text" name="name" value=sandwich.name required) + div.row + div.input-field.col.s12 + label(for="name")=__("admin.name")+":" + input#name(type="text" name="newName" value=sandwich.name required) + div.row + div.input-field.col.s12 + label(for="price")=__("admin.price") + ":" + input#price(type="number" min="0" step="any" name="price" value=sandwich.price required) + div.row.center + div.input-field.col.s12 + +submit(__("save")) diff --git a/views/admin/sandwiches/index.pug b/views/admin/sandwiches/index.pug index abeab8d..bb9f254 100644 --- a/views/admin/sandwiches/index.pug +++ b/views/admin/sandwiches/index.pug @@ -1,18 +1,20 @@ extends ../../layout block content - div.card#sandwichesManagement + div.container h1=__("admin.sandwichManagement") - a.add(href="/admin/sandwiches/add") - button=__("admin.add") - div + ul.collection each sandwich in sandwiches - div.sandwich - h2=sandwich.name - div.buttons - a.edit(href="/admin/sandwiches/edit?name="+sandwich.name) - button=__("admin.edit") - a.remove(href="/admin/sandwiches/delete?name="+sandwich.name) - button=__("admin.remove") + li.collection-item + div=sandwich.name + div.secondary-content + a(href="/admin/sandwiches/edit?name="+sandwich.name) + i.material-icons edit + a.delete(href="/admin/sandwiches/delete?name="+sandwich.name) + i.material-icons remove + + div.fixed-action-btn + a.btn-floating.btn-large.blue(href="/admin/sandwiches/add") + i.large.material-icons add script(src="/javascripts/admin/sandwiches.js") From 3c5cb22975f3ab4a6e98e0340bfa17dafb882fda Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 14:44:59 +0200 Subject: [PATCH 10/13] Departments management rework --- public/javascripts/admin/departments.js | 2 +- views/admin/departments/add.pug | 17 ++++++++++------- views/admin/departments/edit.pug | 19 +++++++++++-------- views/admin/departments/index.pug | 24 +++++++++++++----------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/public/javascripts/admin/departments.js b/public/javascripts/admin/departments.js index b64f7b1..29cf219 100644 --- a/public/javascripts/admin/departments.js +++ b/public/javascripts/admin/departments.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 department ?")) ev.preventDefault(); diff --git a/views/admin/departments/add.pug b/views/admin/departments/add.pug index 150c50c..769ebac 100644 --- a/views/admin/departments/add.pug +++ b/views/admin/departments/add.pug @@ -1,11 +1,14 @@ extends ../../layout block content - div.card#departmentsManagement + div.container h1=__("admin.new")+" "+__("department") - form(action="/admin/departments/add" method="POST") - div.field - label(for="name")=__("admin.name")+":" - input#name(type="text" name="name" required) - div.field - input(type="submit" value=__("admin.add")) + div.row + form(action="/admin/departments/add" method="POST") + div.row + div.input-field.col.s12 + label(for="name")=__("admin.name")+":" + input#name(type="text" name="name" required) + div.row.center + div.input-field.col.s12 + +submit(__("admin.add")) diff --git a/views/admin/departments/edit.pug b/views/admin/departments/edit.pug index ef54167..0c96f69 100644 --- a/views/admin/departments/edit.pug +++ b/views/admin/departments/edit.pug @@ -1,12 +1,15 @@ extends ../../layout block content - div.card#departmentsManagement + div.container h1=__("admin.edit")+" "+department.name - form(action="/admin/departments/edit" method="POST") - input.hide(type="text" name="name" value=department.name required) - div.field - label(for="name")=__("admin.name")+":" - input#name(type="text" name="newName" value=department.name required) - div.field - input(type="submit" value=__("save")) + div.row + form(action="/admin/departments/edit" method="POST") + input.hide(type="text" name="name" value=department.name required) + div.row + div.input-field.col.s12 + label(for="name")=__("admin.name")+":" + input#name(type="text" name="newName" value=department.name required) + div.row.center + div.input-field.col.s12 + +submit(__("save")) diff --git a/views/admin/departments/index.pug b/views/admin/departments/index.pug index fdd70b7..e2b9f62 100644 --- a/views/admin/departments/index.pug +++ b/views/admin/departments/index.pug @@ -1,18 +1,20 @@ extends ../../layout block content - div.card#departmentsManagement + div.container h1=__("admin.departmentsManagement") - a.add(href="/admin/departments/add") - button=__("admin.add") - div + ul.collection each department in departments - div.department - h2=department.name - div.buttons - a.edit(href="/admin/departments/edit?name="+department.name) - button=__("admin.edit") - a.remove(href="/admin/departments/delete?name="+department.name) - button=__("admin.remove") + li.collection-item + div=department.name + div.secondary-content + a(href="/admin/departments/edit?name="+department.name) + i.material-icons edit + a.delete(href="/admin/departments/delete?name="+department.name) + i.material-icons remove + + div.fixed-action-btn + a.btn-floating.btn-large.blue(href="/admin/departments/add") + i.large.material-icons add script(src="/javascripts/admin/departments.js") From 41dad395b2ddc65836607b8151ebebfc09dc2034 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 14:56:47 +0200 Subject: [PATCH 11/13] 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") From 12d4256021f8fe91530118a73a371b09fd0abe88 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 16:12:43 +0200 Subject: [PATCH 12/13] More, about & contact rework --- app.js | 2 + locales/en.json | 4 +- locales/fr.json | 4 +- public/javascripts/layout.js | 25 +--- public/stylesheets/style.css | 272 +---------------------------------- routes/about.js | 9 ++ routes/contact.js | 6 +- views/about.pug | 35 +++++ views/contact.pug | 41 +++++- views/layout.pug | 85 +++-------- 10 files changed, 118 insertions(+), 365 deletions(-) create mode 100644 routes/about.js create mode 100644 views/about.pug diff --git a/app.js b/app.js index 6fc741c..6582cd9 100644 --- a/app.js +++ b/app.js @@ -20,6 +20,7 @@ let profileRouter = require("./routes/profile"); let checkRouter = require("./routes/check"); let adminRouter = require("./routes/admin"); let contactRouter = require("./routes/contact"); +let aboutRouter = require("./routes/about"); let app = express(); let sess = { @@ -76,6 +77,7 @@ app.use("/profile", profileRouter); app.use("/check", checkRouter); app.use("/admin", adminRouter); app.use("/contact", contactRouter); +app.use("/about", aboutRouter); // catch 404 and forward to error handler app.use((req, res) => { diff --git a/locales/en.json b/locales/en.json index dc3b259..a6718e5 100644 --- a/locales/en.json +++ b/locales/en.json @@ -24,7 +24,9 @@ "question": "Practical question", "profile": "My profile", "other": "Another question", - "powered": "Powered by" + "powered": "Powered by", + "links": "Links", + "chooseSubject": "Choose a subject" }, "index": { "welcome": "Welcome to Sandwiches Order Doua", diff --git a/locales/fr.json b/locales/fr.json index 04b7836..bea7027 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -24,7 +24,9 @@ "question": "Question Pratique", "profile": "Mon profil", "other": "Autre question", - "powered": "Propulsé par" + "powered": "Propulsé par", + "links": "Liens", + "chooseSubject": "Choisissez un sujet" }, "index": { "welcome": "Bienvenue sur Sandwiches Order Doua", diff --git a/public/javascripts/layout.js b/public/javascripts/layout.js index 7dbd804..a97274c 100644 --- a/public/javascripts/layout.js +++ b/public/javascripts/layout.js @@ -1,29 +1,6 @@ -const more = document.getElementById("more"); -const dark = document.getElementById("dark"); -const about = document.getElementById("about"); -const contact = document.getElementById("contact"); - - -more.firstChild.addEventListener("click", () => { - dark.classList.remove("hide"); - about.classList.remove("hide"); -}); - -more.lastChild.addEventListener("click", () => { - dark.classList.remove("hide"); - contact.classList.remove("hide") -}); - -dark.addEventListener("click", () => { - dark.classList.add("hide"); - if (! about.classList.contains("hide")) - about.classList.add("hide"); - else - contact.classList.add("hide"); -}); - document.addEventListener("DOMContentLoaded", function() { M.AutoInit(); + M.updateTextFields; }); function cb(token) { diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index c1f2317..a2a7ebf 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -1,271 +1,9 @@ -html, body { - margin: 0; - height: 100%; -} - body { - display: flex; - align-items: center; - font: large "Lucida Grande", Helvetica, Arial, sans-serif; - background-color: #db970a; - background-image: linear-gradient(white 2px, transparent 2px), - linear-gradient(90deg, white 2px, transparent 2px), - linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px), - linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px); - background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; - background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px; + display: flex; + min-height: 100vh; + flex-direction: column; } -.card { - display: flex; - flex-direction: column; - width: max-content; - height: auto; - padding: 1em; - margin: auto; - background-color: white; - box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2); -} - -h1, h2, h3, p, label { - display: block; - text-align: center; -} - -a { - color: #00B7FF; - cursor: pointer; - text-decoration: none; -} - -#order { - margin: auto; - display: flex; - flex-direction: column; -} - -.field { - margin: 1em auto auto auto; - width: 90%; -} - -.field input { - box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2); - margin: auto; - width: 100%; - font-size: 100%; - height: 2.5vh; - border-top: none; - border-left: none; - border-right: none; - border-bottom: 1px gray solid; -} - -.field input[type="radio"], .field input[type="checkbox"] { - box-shadow: none; -} - -.field input[type="submit"] { - height: 4vh; - border: none; -} - -#order-action { - display: flex; - justify-content: space-around; -} - -#add-order, #remove-order { - font-weight: bold; - font-size: 2em; - margin: auto auto 1em auto; -} - -.hide { - display: none; -} - -#more { - display: flex; - position: fixed; - bottom: 0; - left: 0; - padding: 0.3em; - background-color: white; - box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2); - border-radius: 0.5em 0.5em 0 0; -} - -#more a { - margin: 0.1em; - color: black; - text-decoration: underline; -} - -#contact .cont { - display: flex; - justify-content: space-between; -} - -#contact .cont .field { - margin: 0.5em; -} - -.field.message { - width: max-content; - height: max-content; -} - -.message>textarea { - width: 60vw; - height: 30vh; - overflow: auto; - resize: none; - font-size: large; -} - -.popup { - position: fixed; - top: 0; - left: 0; - bottom: 0; - right: 0; - height: max-content; - width: max-content; - max-height: 100%; - max-width: 90%; -} - -.images { - display: flex; - justify-content: space-around; - flex-wrap: wrap; - overflow-y: auto; -} - -.images>div { - display: flex; - align-items: center; - flex-direction: column; - margin: 1em; -} - -.images img { - height: 5em; -} - -p.before-link a::before { - content: " "; -} - -#dark { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: rgba(52, 55, 55, .4); -} - -#date-selector { - position: fixed; - top: 0; - left: 0; - border-radius: 0 0 0.5em 0.5em; -} - -.department { - box-shadow: 0.3em 0.3em 0.3em rgba(0, 0, 255, .2); -} - -.sandwich { - display: flex; - margin-left: 1em; -} - -.buttons { - display: flex; - justify-content: space-around; -} - -#user { - position: fixed; - top: 0; - right: 0; - display: flex; - padding: 0.3em; - background-color: white; - border-radius: 0 0 0.3em 0.3em; - box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2); -} - -#user>p, #user>a { - margin: 0.1em; -} - -#user>a { - text-decoration: underline; - color: black; -} - -#userOrderList { - max-height: 90%; - overflow-y: auto; -} - -#ordersManagement, #sandwichesManagement { - max-height: 90%; -} - -#ordersManagement h2 { - margin: 0.2em 0 0 0; -} - -#ordersManagement>div, #sandwichesManagement>div { - overflow-y: auto; -} - -#ordersManagement .order { - box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2); -} - -#ordersManagement .order .title, #ordersManagement .sandwich { - display: flex; - justify-content: center; -} - -#ordersManagement input[value="x"] { - border: none; - background-color: unset; - cursor: pointer; -} - -#sandwichesManagement>a>button, #departmentsManagement>a>button, #usersManagement>a>button, #ordersManagement>a>button { - width: 100%; -} - -.give { - height: min-content; - width: min-content; -} - -input[type="list"]::-webkit-calendar-picker-indicator { - display: none;/* remove default arrow */ -} - -.list_arrow:after { - content: url(https://i.stack.imgur.com/i9WFO.png); - margin-left: -20px; - padding: .1em; - pointer-events:none; -} - -@media (hover: none) and (pointer: coarse) { - body { - font-size: xx-large; - } - - .message>textarea { - font-size: xx-large; - } +main { + flex: 1 0 auto; } diff --git a/routes/about.js b/routes/about.js new file mode 100644 index 0000000..fc2f0de --- /dev/null +++ b/routes/about.js @@ -0,0 +1,9 @@ +let express = require("express"); +let router = express.Router(); + + +router.get("/", async (req, res) => { + res.render("about", {title: "SOD - About"}); +}); + +module.exports = router; diff --git a/routes/contact.js b/routes/contact.js index 4f041d7..549ffa8 100644 --- a/routes/contact.js +++ b/routes/contact.js @@ -5,7 +5,9 @@ let reCaptcha = require("../middlewares/reCaptcha"); let Message = require("emailjs").Message; -router.post("/", reCaptcha, async (req, res) => { +router.get("/", async (req, res) => { + res.render("contact", {title: "SOD - Contact", send: req.query.send}); +}).post("/", reCaptcha, async (req, res) => { if (!req.body.firstName || !req.body.lastName || !req.body.email || !req.body.subject || ! req.body.message) return error(req, res, "Invalid contact form !", 400, "Missing arg"); @@ -25,7 +27,7 @@ ${req.body.message}`, return error(req, res, "Fail to send message !", 500, req.app.get("env") !== "production" ? err : undefined); else - res.render("contact", {title: "SOD - Contact"}); + res.redirect("/contact?send=1"); }); }); diff --git a/views/about.pug b/views/about.pug new file mode 100644 index 0000000..5689512 --- /dev/null +++ b/views/about.pug @@ -0,0 +1,35 @@ +extends layout + +block content + div.container.center + h1=__("layout.about") + h6=__("layout.aboutDescription") + div.row + div.col.s4.m4 + div.card + div.card-image + img(src="/images/logoBio.png") + div.card-content=__("layout.bio") + div.col.s4.m4 + div.card + div.card-image + img(src="/images/logoChimie.png") + div.card-content=__("layout.chemistry") + div.col.s4.m4 + div.card + div.card-image + img(src="/images/logoGCGP.png") + div.card-content=__("layout.GCPD") + div.row + div.col.s4.m4 + div.card + div.card-image + img(src="/images/logoGEA.png") + div.card-content=__("layout.GEA") + div.col.s4.m4 + div.card + div.card-image + img(src="/images/logoInfo.png") + div.card-content=__("layout.IT") + p.before-link + a(href="" target="_blank") diff --git a/views/contact.pug b/views/contact.pug index 06c785a..1bc5ab4 100644 --- a/views/contact.pug +++ b/views/contact.pug @@ -1,6 +1,43 @@ extends layout block content - div.card + div.container h1=__("contact") - p=__("messageSend") + if !send + div.row + form(method="POST") + div.row + div.input-field.col.s6 + input#firstNameContact(type="text" name="firstName" value=user ? user.firstName : "" required) + label(for="firstNameContact")="* " + __("firstName") + div.input-field.col.s6 + input#lastNameContact(type="text" name="lastName" value=user ? user.lastName : "" required) + label(for="lastNameContact")="* " + __("lastName") + div.row + div.input-field.col.s6 + input#emailContact(type="email" name="email" value=user ? user.email : "" required) + label(for="emailContact")="* " + __("email") + div.input-field.col.s6 + input#phoneNumberContact(type="tel" name="phoneNumber") + label(for="phoneNumberContact")=__("layout.phoneNumber") + div.row + div.input-field.col.s12 + select(name="subject" required) + option(value="" selected disabled)=__("layout.chooseSubject") + option(value=__("layout.commandEdit"))=__("layout.commandEdit") + option(value=__("layout.commandRemove"))=__("layout.commandRemove") + option(value=__("layout.question"))=__("layout.question") + option(value=__("layout.profile"))=__("layout.profile") + option(value=__("layout.other"))=__("layout.other") + label="* " + __("layout.subject") + p.center: strong=__("layout.warnMessage") + div.row + div.input-field.col.s12 + textarea#messageContact.materialize-textarea(name="message" required) + label(for="messageContact")=__("layout.message") + div.row.center + div.input-field.col.s12 + +submit(__("send")) + + else + h5=__("messageSend") diff --git a/views/layout.pug b/views/layout.pug index 912f7cd..4ebd1dd 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -6,7 +6,7 @@ html title= title link(rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons") link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css") - //link(rel="stylesheet" href="/stylesheets/style.css") + link(rel="stylesheet" href="/stylesheets/style.css") meta(name="viewport" content="width=device-width, initial-scale=1.0") body mixin nav @@ -30,75 +30,24 @@ html +nav ul#mobile-nav.sidenav +nav + main + block content - block content + if !test + p !{captcha} - .hide - div#more - a=__("layout.about") - a=__("contact") - - div#dark.hide - div#about.popup.card.hide - h1=__("layout.about") - p=__("layout.aboutDescription") - div.images - div - img(src="/images/logoBio.png") - p=__("layout.bio") - div - img(src="/images/logoChimie.png") - p=__("layout.chemistry") - div - img(src="/images/logoGC.png") - p=__("layout.GC") - div - img(src="/images/logoGCGP.png") - p=__("layout.GCPD") - div - img(src="/images/logoGEA.png") - p=__("layout.GEA") - div - img(src="/images/logoInfo.png") - p=__("layout.IT") - p.before-link=__("layout.made") - a(href="https://www.linkedin.com/in/florian-charlaix" target="_blank") Florian Charlaix - p.before-link=__("layout.powered") - a(href="https://sapinet.fr" target="_blank") Sapinet - div#contact.popup.card.hide - h1=__("contact") - form(action="/contact" method="POST") - div.cont - div.field - label(for="firstNameContact")="* "+__("firstName") - input#firstNameContact(type="text" name="firstName" value=user?user.firstName:"" required) - div.field - label(for="lastNameContact")="* "+__("lastName") - input#lastNameContact(type="text" name="lastName" value=user ? user.lastName : "" required) - div.cont - div.field - label(for="emailContact")="* "+__("email") - input#emailContact(type="email" name="email" value=user ? user.email : "" required) - div.field - label(for="phoneNumberContact")=__("layout.phoneNumber") - input#phoneNumberContact(type="tel" name="phoneNumber") - div.field - label(for="subjectContact")="* "+__("layout.subject") - +list("subjectContact", "subjectContactList", "subject", "", "off", true) - datalist#subjectContactList - option(value=__("layout.commandEdit")) - option(value=__("layout.commandRemove")) - option(value=__("layout.question")) - option(value=__("layout.profile")) - option(value=__("layout.other")) - p=__("layout.warnMessage") - div.field.message - label(for="messageContact")=__("layout.message") - textarea#messageContact(name="message" required) - div.field - +submit(value=__("send")) + footer.page-footer + div.container + div.row + div.col.l6.s12 + h5.white-text=__("layout.links") + ul + li: a.grey-text.text-lighten-3(href="/about")=__("layout.about") + li: a.grey-text.text-lighten-3(href="/contact")=__("contact") + div.footer-copyright + div.container + a.grey-text.text-lighten-4(href="https://sapinet.fr" target="_blank")=__("layout.powered") + " Sapinet" + a.grey-text.text-lighten-4.right(href="https://www.linkedin.com/in/florian-charlaix" target="_blank")=__("layout.made") + " Florian Charlaix" script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js") script(src="/javascripts/layout.js") - if !test - p !{captcha} From e5f9952ed51b8114c2433be5cf024b66461febfc Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 16:17:47 +0200 Subject: [PATCH 13/13] Error & payment rework --- locales/en.json | 1 + locales/fr.json | 1 + views/error.pug | 8 ++++---- views/mixin.pug | 4 ---- views/order.pug | 13 ++++++------- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/locales/en.json b/locales/en.json index a6718e5..f50770d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -77,6 +77,7 @@ "chooseUser": "Choose an user" }, "payment": { + "payment": "Payment", "successful": "Payment successful !", "canceled": "Payment canceled", "error": "An error occurred with the payment", diff --git a/locales/fr.json b/locales/fr.json index bea7027..6b1b91e 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -77,6 +77,7 @@ "chooseUser": "Choisissez un utilisateur" }, "payment": { + "payment": "Paiement", "successful": "Paiement réussi !", "canceled": "Paiement annulé", "error": "Une erreur est survenue lors du paiement", diff --git a/views/error.pug b/views/error.pug index 9c621a6..506af40 100644 --- a/views/error.pug +++ b/views/error.pug @@ -1,7 +1,7 @@ extends layout block content - div.card - h1= message - h2= error.status - pre #{error.stack} + div.container.center + h1=message + h3=error.status + h5=error.stack diff --git a/views/mixin.pug b/views/mixin.pug index a8af50a..1c45b53 100644 --- a/views/mixin.pug +++ b/views/mixin.pug @@ -2,7 +2,3 @@ mixin submit(value) div.recaptcha.recaptcha-cb button.btn.waves-effect.waves-light(type="submit" name="action")=value i.material-icons.right send - -mixin list(id, list, name, value="", autocomplete="on", required=false) - span.list_arrow - input(id=id type="list" list=list name=name value=value autocomplete=autocomplete required=required) diff --git a/views/order.pug b/views/order.pug index 0c5ee05..c08f936 100644 --- a/views/order.pug +++ b/views/order.pug @@ -1,14 +1,13 @@ extends layout block content - div.card - h1 Payment + div.container.center + h1=__("payment.payment") if (state === "success") - h2=__("payment.successful") + h4=__("payment.successful") else if (state === "cancel") - h2=__("payment.canceled") + h4=__("payment.canceled") else if (state === "error") - h2=__("payment.error") + h4=__("payment.error") if (state !== "success") - a(href="/order/retry") - button=__("payment.retry") + a.waves-effect.waves-teal.btn(href="/order/retry")=__("payment.retry")