check the checkbox in a devices list when one form is invalid 2

This commit is contained in:
Cayo Puigdefabregas 2022-02-04 13:22:47 +01:00
parent a55944e379
commit c340122d87
2 changed files with 19 additions and 11 deletions

View File

@ -45,6 +45,11 @@ class DeviceListMix(View):
form_new_action = NewActionForm()
form_new_allocate = AllocateForm()
action_devices = form_new_action.devices.data
list_devices = []
if action_devices:
list_devices.extend([int(x) for x in action_devices.split(",")])
self.context = {
'devices': devices,
'lots': lots,
@ -53,7 +58,8 @@ class DeviceListMix(View):
'form_new_action': form_new_action,
'form_new_allocate': form_new_allocate,
'lot': lot,
'tags': tags
'tags': tags,
'list_devices': list_devices
}
return self.context

View File

@ -12,34 +12,34 @@ $(document).ready(function() {
function deviceSelect() {
var devices_count = $(".deviceSelect").filter(':checked').length;
if (devices_count == 0) {
$("#addingLotModal .text-danger").show();
$("#addingLotModal .pol").show();
$("#addingLotModal .btn-primary").hide();
$("#removeLotModal .text-danger").show();
$("#removeLotModal .pol").show();
$("#removeLotModal .btn-primary").hide();
$("#addingTagModal .text-danger").show();
$("#addingTagModal .pol").show();
$("#addingTagModal .btn-primary").hide();
$("#actionModal .text-danger").show();
$("#actionModal .pol").show();
$("#actionModal .btn-primary").hide();
$("#allocateModal .text-danger").show();
$("#allocateModal .pol").show();
$("#allocateModal .btn-primary").hide();
} else {
$("#addingLotModal .text-danger").hide();
$("#addingLotModal .pol").hide();
$("#addingLotModal .btn-primary").show();
$("#removeLotModal .text-danger").hide();
$("#removeLotModal .pol").hide();
$("#removeLotModal .btn-primary").show();
$("#actionModal .text-danger").hide();
$("#actionModal .pol").hide();
$("#actionModal .btn-primary").show();
$("#allocateModal .text-danger").hide();
$("#allocateModal .pol").hide();
$("#allocateModal .btn-primary").show();
$("#addingTagModal .text-danger").hide();
$("#addingTagModal .pol").hide();
}
}
@ -57,6 +57,7 @@ function newAction(action) {
$("#actionModal #type").val(action);
$("#actionModal #title-action").html(action);
get_device_list();
deviceSelect();
$("#activeActionModal").click();
}
@ -64,6 +65,7 @@ function newAllocate(action) {
$("#allocateModal #type").val(action);
$("#allocateModal #title-action").html(action);
get_device_list();
deviceSelect();
$("#activeAllocateModal").click();
}