From 3da1bdcad17ad68c7635715c95f101607b12319f Mon Sep 17 00:00:00 2001 From: RubenPX Date: Mon, 9 May 2022 14:40:28 +0200 Subject: [PATCH] Show selected devices notify instead page select --- ereuse_devicehub/static/js/main_inventory.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 848c72e4..3d355574 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -85,24 +85,26 @@ window.addEventListener("DOMContentLoaded", () => { function itemListCheckChanged() { const listDevices = TableController.getAllDevicesInCurrentPage() const isAllChecked = listDevices.map(itm => itm.checked); + alertInfoDevices.innerHTML = `Selected devices: ${TableController.getSelectedDevices().length} + ${TableController.getAllDevices().length != TableController.getSelectedDevices().length + ? `Select all devices (${TableController.getAllDevices().length})` + : "Cancel selection" + }`; + + if (TableController.getAllDevices().length > 0) { + alertInfoDevices.classList.remove("d-none"); + } else { + alertInfoDevices.classList.add("d-none") + } if (isAllChecked.every(bool => bool == true)) { btnSelectAll.checked = true; btnSelectAll.indeterminate = false; - alertInfoDevices.innerHTML = `Selected devices: ${TableController.getSelectedDevices().length} - ${ - 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)) { btnSelectAll.checked = false; btnSelectAll.indeterminate = false; - alertInfoDevices.classList.add("d-none") } else { btnSelectAll.indeterminate = true; - alertInfoDevices.classList.add("d-none") } }