From 94c7816983812868e7dfb9c072f630734c280d9e Mon Sep 17 00:00:00 2001 From: Petro Date: Fri, 3 Nov 2023 12:02:21 +0200 Subject: [PATCH] block calculation button during calculation --- app/static/css/main.css | 5 +++++ app/static/js/calculator/actions.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/app/static/css/main.css b/app/static/css/main.css index 00df25e..d5fb4dd 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -423,3 +423,8 @@ li { width: 100% !important; } } + +.disabledButton { + pointer-events: none; + opacity: 0.4; +} diff --git a/app/static/js/calculator/actions.js b/app/static/js/calculator/actions.js index f6a916f..3e8a377 100644 --- a/app/static/js/calculator/actions.js +++ b/app/static/js/calculator/actions.js @@ -36,6 +36,7 @@ document.addEventListener("DOMContentLoaded", (event) => { message: "Start calculating. Please wait...", timeout: 0, }); + calculateBtn.classList.add("disabledButton"); // binsResultsDiv.innerHTML = ""; imagesResultDiv.innerHTML = ""; let addedBins = []; @@ -59,6 +60,7 @@ document.addEventListener("DOMContentLoaded", (event) => { iziToast.error({ message: "Incorrect sheet sizes", }); + calculateBtn.classList.remove("disabledButton"); return; } @@ -81,6 +83,7 @@ document.addEventListener("DOMContentLoaded", (event) => { iziToast.error({ message: "Incorrect artwork sizes", }); + calculateBtn.classList.remove("disabledButton"); return; } addedRects.push({ @@ -129,6 +132,7 @@ document.addEventListener("DOMContentLoaded", (event) => { title: "Error", message: e.message, }); + calculateBtn.classList.remove("disabledButton"); return; } @@ -138,6 +142,7 @@ document.addEventListener("DOMContentLoaded", (event) => { position: "bottomRight", title: "Calculation Error", }); + calculateBtn.classList.remove("disabledButton"); return; } @@ -149,6 +154,7 @@ document.addEventListener("DOMContentLoaded", (event) => { title: "Error", message: resJson.message, }); + calculateBtn.classList.remove("disabledButton"); return; } usageResQtyDiv.innerHTML = resJson.used_area.toFixed(2); @@ -188,5 +194,6 @@ document.addEventListener("DOMContentLoaded", (event) => { position: "bottomRight", title: "Success", }); + calculateBtn.classList.remove("disabledButton"); }); });