} selectedDevicesIDs
- * @param {HTMLElement} target
+ * @param {Object} lot Lot model server
+ * @param {Device[]} selectedDevices list selected devices
+ * @param {HTMLElement} elementTarget
+ * @param {Action[]} actions
*/
- function templateLot(lot, elementTarget, actions) {
+ function templateLot(lot, selectedDevices, elementTarget, actions) {
elementTarget.innerHTML = ""
- const {id, name, state} = lot;
+ const { id, name, state } = lot;
const htmlTemplate = `
`;
@@ -345,16 +451,17 @@ async function processSelectedDevices() {
break;
}
- doc.children[0].addEventListener("mouseup", (ev) => actions.manage(ev, id, selectedDevicesIDs));
- doc.children[1].addEventListener("mouseup", (ev) => actions.manage(ev, id, selectedDevicesIDs));
+ doc.children[0].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices));
+ doc.children[1].addEventListener("mouseup", (ev) => actions.manage(ev, lot, selectedDevices));
elementTarget.append(doc);
}
const listHTML = $("#LotsSelector")
// Get selected devices
- const selectedDevicesIDs = $.map($(".deviceSelect").filter(":checked"), (x) => parseInt($(x).attr("data")));
- if (selectedDevicesIDs.length <= 0) {
+ const selectedDevicesID = TableController.ProcessTR(TableController.getSelectedDevices()).map(item => item.data)
+
+ if (selectedDevicesID.length <= 0) {
listHTML.html("No devices selected");
return;
}
@@ -369,19 +476,19 @@ async function processSelectedDevices() {
try {
listHTML.html("")
- const devices = await Api.get_devices(selectedDevicesIDs);
+ const selectedDevices = await Api.get_devices(selectedDevicesID);
let lots = await Api.get_lots();
lots = lots.map(lot => {
- lot.devices = devices
+ lot.devices = selectedDevices
.filter(device => device.lots.filter(devicelot => devicelot.id == lot.id).length > 0)
.map(device => parseInt(device.id));
- switch (lot.devices.length) {
+ switch (lot.devices.length) {
case 0:
lot.state = "false";
break;
- case selectedDevicesIDs.length:
+ case selectedDevicesID.length:
lot.state = "true";
break;
default:
@@ -392,15 +499,14 @@ async function processSelectedDevices() {
return lot;
})
-
let lotsList = [];
- lotsList.push(lots.filter(lot => lot.state == "true").sort((a,b) => a.name.localeCompare(b.name)));
- lotsList.push(lots.filter(lot => lot.state == "indetermined").sort((a,b) => a.name.localeCompare(b.name)));
- lotsList.push(lots.filter(lot => lot.state == "false").sort((a,b) => a.name.localeCompare(b.name)));
+ lotsList.push(lots.filter(lot => lot.state == "true").sort((a, b) => a.name.localeCompare(b.name)));
+ lotsList.push(lots.filter(lot => lot.state == "indetermined").sort((a, b) => a.name.localeCompare(b.name)));
+ lotsList.push(lots.filter(lot => lot.state == "false").sort((a, b) => a.name.localeCompare(b.name)));
lotsList = lotsList.flat(); // flat array
listHTML.html("");
- lotsList.forEach(lot => templateLot(lot, listHTML, actions));
+ lotsList.forEach(lot => templateLot(lot, selectedDevices, listHTML, actions));
} catch (error) {
console.log(error);
listHTML.html("Error feching devices and lots
(see console for more details)");
diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html
index b95334f8..1a58e5de 100644
--- a/ereuse_devicehub/templates/inventory/device_list.html
+++ b/ereuse_devicehub/templates/inventory/device_list.html
@@ -308,6 +308,10 @@
{% endif %}
+
+ If this text is showing is because there are an error
+
+