Plate can avoid sauce
This commit is contained in:
parent
13adbc8197
commit
aed4b62f07
3 changed files with 13 additions and 3 deletions
|
@ -65,6 +65,7 @@ class Plate(db.Model):
|
||||||
|
|
||||||
price = db.Column(db.Integer, default=0)
|
price = db.Column(db.Integer, default=0)
|
||||||
avoid_ingredient = db.Column(db.Boolean, default=False)
|
avoid_ingredient = db.Column(db.Boolean, default=False)
|
||||||
|
avoid_sauce = db.Column(db.Boolean, default=False)
|
||||||
|
|
||||||
command = db.relationship("Command", backref="plate", lazy="dynamic")
|
command = db.relationship("Command", backref="plate", lazy="dynamic")
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,8 @@ def errcmd(json):
|
||||||
def lsplate():
|
def lsplate():
|
||||||
plates = []
|
plates = []
|
||||||
for p in Plate.query.all():
|
for p in Plate.query.all():
|
||||||
plates.append({"id": p.id, "name": p.name, "price": p.price, "avoid ingredient": p.avoid_ingredient})
|
plates.append({"id": p.id, "name": p.name, "price": p.price, "avoid_ingredient": p.avoid_ingredient,
|
||||||
|
"avoid_sauce": p.avoid_sauce})
|
||||||
emit("list plate", {"list": plates})
|
emit("list plate", {"list": plates})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ function addplate(id, name) {
|
||||||
let e = document.querySelector(`input[id=${id} ]`);
|
let e = document.querySelector(`input[id=${id} ]`);
|
||||||
e.addEventListener("click", () => {
|
e.addEventListener("click", () => {
|
||||||
radiocheck(e, "plate",0);
|
radiocheck(e, "plate",0);
|
||||||
document.querySelectorAll("input[name=ingredient],input[name=sauce]").forEach( el => {
|
document.querySelectorAll("input[name=ingredient]").forEach( el => {
|
||||||
if (e.checked && !db["plate"][e.id]["avoid ingredient"])
|
if (e.checked && !db["plate"][e.id]["avoid ingredient"])
|
||||||
el.disabled = false;
|
el.disabled = false;
|
||||||
else {
|
else {
|
||||||
|
@ -62,6 +62,14 @@ function addplate(id, name) {
|
||||||
el.checked = false
|
el.checked = false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
document.querySelectorAll("input[name=sauce]").forEach( el => {
|
||||||
|
if (e.checked && !db["plate"][e.id]["avoid sauce"])
|
||||||
|
el.disabled = false;
|
||||||
|
else {
|
||||||
|
el.disabled = true;
|
||||||
|
el.checked = false
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +215,7 @@ socket.on("list plate", data => {
|
||||||
}
|
}
|
||||||
for (let p of data.list) {
|
for (let p of data.list) {
|
||||||
addplate(p.id, p.name);
|
addplate(p.id, p.name);
|
||||||
db["plate"][p.id] = {"name": p.name, "price": p.price, "avoid ingredient": p["avoid ingredient"]}
|
db["plate"][p.id] = {"name": p.name, "price": p.price, "avoid ingredient": p.avoid_ingredient, "avoid sauce": p.avoid_sauce}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Reference in a new issue