Fix re render table

This commit is contained in:
RubenPX 2022-04-28 15:01:39 +02:00
parent 293364acfb
commit bb284008cc
1 changed files with 10 additions and 12 deletions

View File

@ -299,15 +299,13 @@ async function processSelectedDevices() {
const tmpDiv = document.createElement("div") const tmpDiv = document.createElement("div")
tmpDiv.innerHTML = newRequest tmpDiv.innerHTML = newRequest
const oldTable = Array.from(document.querySelectorAll("table.table > tbody > tr .deviceSelect")).map(x => x.attributes["data-device-dhid"].value)
const newTable = Array.from(tmpDiv.querySelectorAll("table.table > tbody > tr .deviceSelect")).map(x => x.attributes["data-device-dhid"].value) const newTable = Array.from(tmpDiv.querySelectorAll("table.table > tbody > tr .deviceSelect")).map(x => x.attributes["data-device-dhid"].value)
for (let i = 0; i < oldTable.length; i++) { table.rows().dt.activeRows.forEach(row => {
if (!newTable.includes(oldTable[i])) { if (!newTable.includes(row.querySelector("input").attributes["data-device-dhid"].value)) {
// variable from device_list.html --> See: ereuse_devicehub\templates\inventory\device_list.html (Ln: 411) row.remove()
table.rows().remove(i)
} }
} })
} }
} }
@ -352,12 +350,12 @@ async function processSelectedDevices() {
const listHTML = $("#LotsSelector") const listHTML = $("#LotsSelector")
// Get selected devices // Get selected devices
const selectedDevicesIDs = $.map($(".deviceSelect").filter(":checked"), (x) => parseInt($(x).attr("data"))); const selectedDevicesIDs = $.map($(".deviceSelect").filter(":checked"), (x) => parseInt($(x).attr("data")));
if (selectedDevicesIDs.length <= 0) { if (selectedDevicesIDs.length <= 0) {
listHTML.html("<li style=\"color: red; text-align: center\">No devices selected</li>"); listHTML.html("<li style=\"color: red; text-align: center\">No devices selected</li>");
return; return;
} }
// Initialize Actions list, and set checkbox triggers // Initialize Actions list, and set checkbox triggers
const actions = new Actions(); const actions = new Actions();