add Search functionality
This commit is contained in:
parent
adde4f88e4
commit
a10fb5a212
|
@ -317,6 +317,26 @@ function export_file(type_file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class lotsSearcher {
|
||||||
|
static lots = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* do search when lot change in the search input
|
||||||
|
*/
|
||||||
|
static doSearch(inputSearch) {
|
||||||
|
lotsSearcher.lots.map((lot) => {
|
||||||
|
if (lot.querySelector("label").innerText.toLowerCase().includes(inputSearch.toLowerCase())) {
|
||||||
|
lot.style.display = "block";
|
||||||
|
} else {
|
||||||
|
lot.style.display = "none";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
document.getElementById("lots-search").addEventListener("input", (e) => { lotsSearcher.doSearch(e.target.value) })
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reactive lots button
|
* Reactive lots button
|
||||||
|
@ -495,6 +515,7 @@ 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")
|
||||||
|
@ -588,6 +609,7 @@ 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);
|
||||||
|
|
Reference in New Issue