From cc7b453c062d052cda8f160524d884235856e859 Mon Sep 17 00:00:00 2001 From: RubenPX Date: Wed, 11 May 2022 11:19:56 +0200 Subject: [PATCH] Check initial state on dom loaded & check if has devices --- ereuse_devicehub/static/js/main_inventory.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 0f1d9b7e..f48dfe99 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -104,6 +104,13 @@ window.addEventListener("DOMContentLoaded", () => { btnSelectAll.checked = false; btnSelectAll.indeterminate = false; } + + if (TableController.getAllDevices().length == 0) { + btnSelectAll.checked = false; + btnSelectAll.disabled = true; + } else { + btnSelectAll.disabled = false; + } } TableController.getAllDevices().forEach(item => { @@ -126,6 +133,8 @@ window.addEventListener("DOMContentLoaded", () => { table.on("datatable.page", () => itemListCheckChanged()); table.on("datatable.perpage", () => itemListCheckChanged()); table.on("datatable.update", () => itemListCheckChanged()); + + itemListCheckChanged(); }) function deviceSelect() {