From 7f9a6784e9c69ae448326d28ee14993ed7a1335f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Feb 2022 13:58:54 +0100 Subject: [PATCH] add count of devices in action form --- ereuse_devicehub/static/js/main_inventory.js | 14 +++++++++++++- ereuse_devicehub/templates/inventory/actions.html | 11 ++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 32067cbc..2478a420 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -11,15 +11,23 @@ $(document).ready(function() { function deviceSelect() { var devices = $(".deviceSelect").filter(':checked'); + var devices_count = devices.length; var devices_id = $.map(devices, function(x) { return $(x).attr('data')}).join(","); - if (devices_id == "") { + if (devices_count == 0) { $("#addingLotModal .text-danger").show(); $("#addingLotModal .btn-primary").hide(); $("#removeLotModal .text-danger").show(); $("#removeLotModal .btn-primary").hide(); + $("#addingTagModal .text-danger").show(); $("#addingTagModal .btn-primary").hide(); + + $("#actionModal .text-danger").show(); + $("#actionModal .btn-primary").hide(); + + $("#allocateModal .text-danger").show(); + $("#allocateModal .btn-primary").hide(); } else { $("#addingLotModal .text-danger").hide(); $("#addingLotModal .btn-primary").show(); @@ -53,11 +61,15 @@ function removeTag() { function newAction(action) { $("#actionModal #type").val(action); $("#actionModal #title-action").html(action); + devices_count = $(".deviceSelect").filter(':checked').length; + $("#actionModal .devices-count").html(devices_count); $("#activeActionModal").click(); } function newAllocate(action) { $("#allocateModal #type").val(action); $("#allocateModal #title-action").html(action); + devices_count = $(".deviceSelect").filter(':checked').length; + $("#actionModal .devices-count").html(devices_count); $("#activeAllocateModal").click(); } diff --git a/ereuse_devicehub/templates/inventory/actions.html b/ereuse_devicehub/templates/inventory/actions.html index e823f2aa..c74afa41 100644 --- a/ereuse_devicehub/templates/inventory/actions.html +++ b/ereuse_devicehub/templates/inventory/actions.html @@ -10,12 +10,17 @@
{{ form_new_action.csrf_token }}