From 2cce025e58090cc09bf699eced101a1c3ee8b4f9 Mon Sep 17 00:00:00 2001 From: RubenPX Date: Mon, 11 Apr 2022 10:35:26 +0200 Subject: [PATCH] Re-render when completed lots changes --- ereuse_devicehub/static/js/main_inventory.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 73173aab..c6748e4c 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -332,6 +332,7 @@ async function processSelectedDevices() { * Get actions and execute call request to add or remove devices from lots */ doActions() { + var requestCount = 0; // This is for count all requested api count, to perform reRender of table device list this.list.forEach(async action => { if (action.type == "Add") { try { @@ -348,8 +349,25 @@ async function processSelectedDevices() { this.notifyUser("Fail to remove devices from selected lot/s", error.responseJSON.message, true); } } + + requestCount += 1 + if (requestCount == this.list.length) { + this.reRenderTable(); + this.list = [] + } }) - this.list = [] + } + + /** + * Re-render list in table + */ + async reRenderTable() { + var newRequest = await Api.doRequest(window.location) + + var tmpDiv = document.createElement("div") + tmpDiv.innerHTML = newRequest + + document.querySelector("table.table > tbody").innerHTML = tmpDiv.querySelector("table.table > tbody").innerHTML } }