sandwiches & orders rework
This commit is contained in:
parent
80187cf71f
commit
498a2fa977
4 changed files with 27 additions and 36 deletions
|
@ -1,25 +1,17 @@
|
||||||
const date = document.getElementById("date");
|
const date = document.getElementById("date");
|
||||||
|
|
||||||
|
document.querySelectorAll("h4").forEach((e) => {
|
||||||
function collapse(e, subDiv) {
|
|
||||||
e.addEventListener("click", ev => {
|
e.addEventListener("click", ev => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
let action;
|
let action;
|
||||||
if (e.classList.contains("collapse"))
|
if (e.classList.contains("collapsed"))
|
||||||
action = "remove";
|
action = "remove";
|
||||||
else
|
else
|
||||||
action = "add";
|
action = "add";
|
||||||
|
|
||||||
e.querySelectorAll("."+subDiv).forEach(e => e.classList[action]("hide"));
|
e.parentElement.querySelectorAll(".collection").forEach(c => c.classList[action]("hide"));
|
||||||
e.classList[action]("collapse");
|
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);
|
date.addEventListener("change", () => window.location.href = "?date="+date.value);
|
||||||
|
|
|
@ -30,11 +30,11 @@ router.get("/", sessionCheck(2), async (req, res) => {
|
||||||
orders[o.DepartmentName][name][o.id] = o.Sandwiches;
|
orders[o.DepartmentName][name][o.id] = o.Sandwiches;
|
||||||
}
|
}
|
||||||
res.render("orders", {title: "SOD - Orders", orders: orders, date: date});
|
res.render("orders", {title: "SOD - Orders", orders: orders, date: date});
|
||||||
}).post("/give", sessionCheck(2), async (req, res) => {
|
}).get("/give", sessionCheck(2), async (req, res) => {
|
||||||
if (!req.body.id)
|
if (!req.query.id)
|
||||||
return error(req, res, "Missing arg !", 400);
|
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)
|
if (!order)
|
||||||
return error(req, res, "Invalid order id !", 400);
|
return error(req, res, "Invalid order id !", 400);
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,22 @@
|
||||||
extends layout
|
extends layout
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#date-selector.card
|
div.container
|
||||||
label(for="date")=__("date")
|
label(for="date")=__("date")
|
||||||
input#date(type="date" value=date)
|
input#date(type="date" value=date)
|
||||||
div#orders.card
|
div.container
|
||||||
h1=__("orders")
|
h1=__("orders")
|
||||||
each user, department in orders
|
each user, department in orders
|
||||||
div.department
|
div.container
|
||||||
h2= department
|
h4=department
|
||||||
each orders, name in user
|
each orders, name in user
|
||||||
div.user
|
each order, id in orders
|
||||||
h3= name
|
ul.collection.with-header
|
||||||
each order, id in orders
|
li.collection-header: h5 #{name} - #{__("order")} N°#{id}
|
||||||
div.order
|
each sandwich in order
|
||||||
h4 #{__("order")} N°#{id}
|
li.collection-item
|
||||||
each sandwich in order
|
div=sandwich.name
|
||||||
div.sandwich
|
a.secondary-content(href="/orders/give?id="+sandwich.SandwichOrder.id)
|
||||||
form.give(method="POST" action="/orders/give")
|
i.material-icons check
|
||||||
input(type="hidden" name="id" value=sandwich.SandwichOrder.id)
|
|
||||||
input.give(type="submit" value="v")
|
|
||||||
h4= sandwich.name
|
|
||||||
|
|
||||||
script(src="/javascripts/orders.js")
|
script(src="/javascripts/orders.js")
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
extends layout
|
extends layout
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#date-selector.card
|
div.container
|
||||||
label(for="date")=__("date")
|
label(for="date")=__("date")
|
||||||
input#date(type="date" value=date)
|
input#date(type="date" value=date)
|
||||||
div.card
|
div.container
|
||||||
h1=__("sandwiches")
|
h1=__("sandwiches")
|
||||||
each sandwich in sandwiches
|
ul.collection
|
||||||
div.sandwich
|
each sandwich in sandwiches
|
||||||
h2 #{sandwich.name}: #{sandwich.dataValues.number}
|
li.collection-item
|
||||||
|
div=sandwich.name
|
||||||
|
a.secondary-content=sandwich.dataValues.number
|
||||||
|
|
||||||
script(src="/javascripts/sandwiches.js")
|
script(src="/javascripts/sandwiches.js")
|
||||||
|
|
Reference in a new issue