remove code dependecy

This commit is contained in:
RubenPX 2022-05-13 21:54:03 +02:00
parent ec0d9860f7
commit b329474a10
1 changed files with 8 additions and 7 deletions

View File

@ -324,13 +324,16 @@ class lotsSearcher {
* do search when lot change in the search input * do search when lot change in the search input
*/ */
static doSearch(inputSearch) { static doSearch(inputSearch) {
lotsSearcher.lots.forEach((lot) => { const lotsList = document.getElementById("LotsSelector").children;
if (lot.querySelector("label").innerText.toLowerCase().includes(inputSearch.toLowerCase())) {
lot.style.display = "block"; 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 { } 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[0].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices));
doc.children[1].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices)); doc.children[1].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices));
elementTarget.append(doc); elementTarget.append(doc);
lotsSearcher.lots.push(doc);
} }
const listHTML = $("#LotsSelector") const listHTML = $("#LotsSelector")
@ -609,7 +611,6 @@ async function processSelectedDevices() {
lotsList = lotsList.flat(); // flat array lotsList = lotsList.flat(); // flat array
listHTML.html(""); listHTML.html("");
lotsSearcher.lots = [];
lotsList.forEach(lot => templateLot(lot, selectedDevices, listHTML, actions)); lotsList.forEach(lot => templateLot(lot, selectedDevices, listHTML, actions));
} catch (error) { } catch (error) {
console.log(error); console.log(error);