add count of devices in action form

This commit is contained in:
Cayo Puigdefabregas 2022-02-03 13:58:54 +01:00
parent aeef04b92c
commit 7f9a6784e9
2 changed files with 21 additions and 4 deletions

View File

@ -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();
}

View File

@ -10,12 +10,17 @@
<form action="{{ url_for('inventory.devices.action_add') }}" method="post">
{{ form_new_action.csrf_token }}
<div class="modal-body">
<p class="text-danger">
You need select first some device before to do one action
</p>
{% for field in form_new_action %}
{% if field != form_new_action.csrf_token %}
{% if field == form_new_action.devices %}
<div class="col-12">
{{ field.label(class_="form-label") }}: <span class="devices-count"></span>
{{ field(class_="form-control") }}
<p class="text-danger">
You need select first some device before to do one action
</p>
<p class="enumeration-devices"></p>
</div>
{{ field(class_="devicesList") }}
{% elif field == form_new_action.type %}
{{ field(class_="form-control") }}