Merge pull request #259 from RubenPX/fix-indeterminated-checkbox

fix indeterminated checkbox on select lots
This commit is contained in:
Santiago L 2022-05-11 18:43:51 +02:00 committed by GitHub
commit 6a8a38eaab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,6 +111,8 @@ window.addEventListener("DOMContentLoaded", () => {
} else {
btnSelectAll.disabled = false;
}
get_device_list();
}
TableController.getAllDevices().forEach(item => {
@ -324,19 +326,30 @@ async function processSelectedDevices() {
const lotID = lot.id;
const srcElement = event.srcElement.parentElement.children[0]
const checked = !srcElement.checked;
const { indeterminate } = srcElement
const found = this.list.filter(list => list.lot.id == lotID)[0];
if (checked) {
if (found && found.type == "Remove") {
found.type = "Add";
const affectedDevices = found.devices.filter(dev => found.lot.devices.includes(dev.id))
if (affectedDevices.length > 0 && found.indeterminate == false) { // Remove action from list
actions.list = actions.list.filter(x => x.lot.id != found.lot.id)
} else {
found.type = "Add";
}
} else {
this.list.push({ type: "Add", lot, devices: selectedDevices });
this.list.push({ type: "Add", lot, devices: selectedDevices, indeterminate });
}
} else if (found && found.type == "Add") {
found.type = "Remove";
const affectedDevices = found.devices.filter(dev => !found.lot.devices.includes(dev.id))
if (affectedDevices.length > 0 && found.indeterminate == false) { // Remove action from list
actions.list = actions.list.filter(x => x.lot.id != found.lot.id)
} else {
found.type = "Remove";
}
} else {
this.list.push({ type: "Remove", lot, devices: selectedDevices });
this.list.push({ type: "Remove", lot, devices: selectedDevices, indeterminate });
}
if (this.list.length > 0) {