From 3ab7e8796f92ec562797c50a98ea0162d17dfbdb Mon Sep 17 00:00:00 2001 From: RubenPX Date: Tue, 12 Apr 2022 11:39:53 +0200 Subject: [PATCH] Fix use table library api instead replace content https://github.com/fiduswriter/Simple-DataTables --- ereuse_devicehub/static/js/main_inventory.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 1e93c91f..26c68544 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -367,7 +367,15 @@ async function processSelectedDevices() { var tmpDiv = document.createElement("div") tmpDiv.innerHTML = newRequest - document.querySelector("table.table > tbody").innerHTML = tmpDiv.querySelector("table.table > tbody").innerHTML + var oldTable = Array.from(document.querySelectorAll("table.table > tbody > tr .deviceSelect")).map(x => x.attributes["data-device-dhid"].value) + var 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++) { + if (!newTable.includes(oldTable[i])) { + // variable from device_list.html --> See: ereuse_devicehub\templates\inventory\device_list.html (Ln: 411) + table.rows().remove(i) + } + } } }