From 2aab4b49d3bdadc2bb61c91a81d9dea0b9170fc2 Mon Sep 17 00:00:00 2001 From: RubenPX Date: Tue, 3 May 2022 12:52:26 +0200 Subject: [PATCH] Allow user to cancel all selection --- ereuse_devicehub/static/js/main_inventory.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index b7b4387c..a183dd72 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -89,7 +89,7 @@ window.addEventListener("DOMContentLoaded", () => { ${ TableController.getAllDevices().length != TableController.getSelectedDevices().length ? `Select all devices (${TableController.getAllDevices().length})` - : "" + : "Cancel selection" }`; alertInfoDevices.classList.remove("d-none"); } else if (isAllChecked.every(bool => bool == false)) { @@ -113,7 +113,8 @@ window.addEventListener("DOMContentLoaded", () => { }) alertInfoDevices.addEventListener("click", () => { - TableController.getAllDevices().forEach(ckeckbox => { ckeckbox.checked = true }); + const checkState = TableController.getAllDevices().length == TableController.getSelectedDevices().length + TableController.getAllDevices().forEach(ckeckbox => { ckeckbox.checked = !checkState }); itemListCheckChanged() })