fix dropdown not works when try to search DOM element

This commit is contained in:
RubenPX 2022-05-22 18:20:04 +02:00
parent c0a7415f33
commit c13bc0f7ce
2 changed files with 37 additions and 4 deletions

View File

@ -218,9 +218,13 @@
/**
* Avoid hide dropdown when user clicked inside
*/
document.getElementById("dropDownLotsSelector").addEventListener("click", event => {
const dropdownLotSelector = document.getElementById("dropDownLotsSelector")
if (dropdownLotSelector != null) { // If exists selector it will set click event
dropdownLotSelector.addEventListener("click", event => {
event.stopPropagation();
})
}
/**
* Search form functionality

View File

@ -1,5 +1,7 @@
"use strict";
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { _classCheckPrivateStaticAccess(receiver, classConstructor); _classCheckPrivateStaticFieldDescriptor(descriptor, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
function _classCheckPrivateStaticFieldDescriptor(descriptor, action) { if (descriptor === undefined) { throw new TypeError("attempted to " + action + " private static field before its declaration"); } }
@ -328,11 +330,38 @@ function export_file(type_file) {
$("#exportAlertModal").click();
}
}
class lotsSearcher {
/**
* do search when lot change in the search input
*/
static doSearch(inputSearch) {
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.parentElement.style.display = "none";
}
}
}
}
_defineProperty(lotsSearcher, "lots", []);
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("lots-search").addEventListener("input", e => {
lotsSearcher.doSearch(e.target.value);
});
});
/**
* Reactive lots button
*/
async function processSelectedDevices() {
class Actions {
constructor() {