From 1c0b8100229e044b511affdc57fe77d971b4ef50 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 29 Sep 2020 14:39:13 +0200 Subject: [PATCH] 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")