From 1589c709844367950c310f6abaca618ec67ec861 Mon Sep 17 00:00:00 2001 From: flifloo Date: Fri, 6 Mar 2020 17:10:14 +0100 Subject: [PATCH] Round price and fix event when plate changed --- app/static/js/pc.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/static/js/pc.js b/app/static/js/pc.js index b780bae..57f9811 100644 --- a/app/static/js/pc.js +++ b/app/static/js/pc.js @@ -54,21 +54,12 @@ function addplate(id, name) { let e = document.querySelector(`input[id=${id} ]`); e.addEventListener("click", () => { radiocheck(e, "plate",0); - document.querySelectorAll("input[name=ingredient]").forEach( el => { - if (e.checked && !db["plate"][e.id]["avoid ingredient"]) - el.disabled = false; - else { - el.disabled = true; - el.checked = false - } + document.querySelectorAll("input[name=ingredient],input[name=sauce]").forEach( el => { + if (el.checked) + el.click(); }); - 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 - } + document.querySelectorAll("input[name=ingredient],input[name=sauce]").forEach( el => { + el.disabled = !(e.checked && !db["plate"][e.id]["avoid " + el.name]); }); }) } @@ -182,6 +173,7 @@ function price () { for (let i in current["price"]) { p += current["price"][i] } + p = p.toFixed(2); document.querySelector("#resume h2").innerHTML = p+"€"; }