From 02752ee2b82cf04d34ebd7f95c6f90f16a7bff60 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 May 2023 12:58:32 +0200 Subject: [PATCH 1/3] hide submit in filter of list of devices --- ereuse_devicehub/static/js/main_inventory.build.js | 3 +++ ereuse_devicehub/static/js/main_inventory.js | 3 +++ ereuse_devicehub/templates/inventory/device_list.html | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/static/js/main_inventory.build.js b/ereuse_devicehub/static/js/main_inventory.build.js index 0032f649..c4bff9c4 100644 --- a/ereuse_devicehub/static/js/main_inventory.build.js +++ b/ereuse_devicehub/static/js/main_inventory.build.js @@ -30,6 +30,9 @@ $(document).ready(() => { ; select_shift(); // $('#selectLot').selectpicker(); + $("#filter").on("change", () => { + $("#submit_filter").click(); + }); }); class TableController { diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index f5c50241..3088257c 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -16,6 +16,9 @@ $(document).ready(() => { }; select_shift(); // $('#selectLot').selectpicker(); + $("#filter").on("change", () => { + $("#submit_filter").click(); + }); }) class TableController { diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index ec1666a7..426b7b02 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -374,7 +374,7 @@ {% endfor %} - + From acc5f6ed784eecce2b90207300aff7a3fc035c22 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 May 2023 16:14:43 +0200 Subject: [PATCH 2/3] fix devices lot shared --- ereuse_devicehub/templates/inventory/device_list.html | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 426b7b02..82976a38 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -352,12 +352,6 @@ Devices Spreadsheet -
  • - - - Devices Lots Spreadsheet - -
  • {% endif %} From 906dceed56c836a20c60235fae7cbbf1bd471f2c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 May 2023 17:04:08 +0200 Subject: [PATCH 3/3] fix --- ereuse_devicehub/inventory/views.py | 1 - .../static/js/main_inventory.build.js | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 8ccb24f8..7e5a7999 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -1014,7 +1014,6 @@ class ExportsView(View): return export_ids[export_id]() def find_devices(self): - # import pdb; pdb.set_trace() sql = """ select lot_device.device_id as id from {schema}.share_lot as share inner join {schema}.lot_device as lot_device diff --git a/ereuse_devicehub/static/js/main_inventory.build.js b/ereuse_devicehub/static/js/main_inventory.build.js index c4bff9c4..389f4377 100644 --- a/ereuse_devicehub/static/js/main_inventory.build.js +++ b/ereuse_devicehub/static/js/main_inventory.build.js @@ -30,6 +30,7 @@ $(document).ready(() => { ; select_shift(); // $('#selectLot').selectpicker(); + $("#filter").on("change", () => { $("#submit_filter").click(); }); @@ -214,8 +215,8 @@ function removeLot() { } function select_shift() { - const chkboxes = $('.deviceSelect'); - var lastChecked = null; + const chkboxes = $(".deviceSelect"); + let lastChecked = null; chkboxes.click(function (e) { if (!lastChecked) { lastChecked = this; @@ -327,17 +328,16 @@ function export_file(type_file) { function export_actions_erasure(type_file) { const actions = TableController.getSelectedDevices(); - const actions_id = $.map(actions, (x) => $(x).attr("data-action-erasure")).join(","); + const actions_id = $.map(actions, x => $(x).attr("data-action-erasure")).join(","); if (actions_id) { - const url = `/inventory/export/${type_file}/?ids=${actions_id}`; + const url = "/inventory/export/".concat(type_file, "/?ids=").concat(actions_id); window.location.href = url; } else { $("#exportAlertModal").click(); } } - class lotsSearcher { static enable() { if (this.lotsSearchElement) this.lotsSearchElement.disabled = false; @@ -666,19 +666,14 @@ async function processSelectedDevices() { return lot; }); - listHTML.html(""); const lot_temporary = lots.filter(lot => !lot.transfer && !lot.trade); appendMenu(lot_temporary, listHTML, templateLot, selectedDevices, actions, "Temporary"); - const lot_incoming = lots.filter(lot => lot.transfer && lot.transfer == "Incoming"); appendMenu(lot_incoming, listHTML, templateLot, selectedDevices, actions, "Incoming"); - const lot_outgoing = lots.filter(lot => lot.transfer && lot.transfer == "Outgoing"); appendMenu(lot_outgoing, listHTML, templateLot, selectedDevices, actions, "Outgoing"); - lotsSearcher.enable(); - } catch (error) { console.log(error); listHTML.html("
  • Error feching devices and lots
    (see console for more details)
  • "); @@ -692,6 +687,6 @@ function appendMenu(lots, listHTML, templateLot, selectedDevices, actions, title lotsList.push(lots.filter(lot => lot.state == "false").sort((a, b) => a.name.localeCompare(b.name))); lotsList = lotsList.flat(); // flat array - listHTML.append(`
  • ${ title }
  • `); + listHTML.append("
  • ".concat(title, "
  • ")); lotsList.forEach(lot => templateLot(lot, selectedDevices, listHTML, actions)); }