From b329474a1050775ede2af19631542db5f8e7e555 Mon Sep 17 00:00:00 2001 From: RubenPX Date: Fri, 13 May 2022 21:54:03 +0200 Subject: [PATCH] remove code dependecy --- ereuse_devicehub/static/js/main_inventory.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 45808aab..4d978ba5 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -324,13 +324,16 @@ class lotsSearcher { * do search when lot change in the search input */ static doSearch(inputSearch) { - lotsSearcher.lots.forEach((lot) => { - if (lot.querySelector("label").innerText.toLowerCase().includes(inputSearch.toLowerCase())) { - lot.style.display = "block"; + const lotsList = document.getElementById("LotsSelector").children; + + for (let i = 0; i < lotsList.length; i++) { + const lot = lotsList[i].querySelector("label"); + if (lot.innerText.toLowerCase().includes(inputSearch.toLowerCase())) { + lot.parentElement.style.display = ""; } else { - lot.style.display = "none"; + lot.parentElement.style.display = "none"; } - }) + } } } @@ -515,7 +518,6 @@ async function processSelectedDevices() { doc.children[0].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices)); doc.children[1].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices)); elementTarget.append(doc); - lotsSearcher.lots.push(doc); } const listHTML = $("#LotsSelector") @@ -609,7 +611,6 @@ async function processSelectedDevices() { lotsList = lotsList.flat(); // flat array listHTML.html(""); - lotsSearcher.lots = []; lotsList.forEach(lot => templateLot(lot, selectedDevices, listHTML, actions)); } catch (error) { console.log(error);