Refactor to reduche changes code
This commit is contained in:
parent
2cce025e58
commit
06456b352f
|
@ -1,4 +1,4 @@
|
||||||
$(document).ready(function () {
|
$(document).ready(function() {
|
||||||
var show_allocate_form = $("#allocateModal").data('show-action-form');
|
var show_allocate_form = $("#allocateModal").data('show-action-form');
|
||||||
var show_datawipe_form = $("#datawipeModal").data('show-action-form');
|
var show_datawipe_form = $("#datawipeModal").data('show-action-form');
|
||||||
var show_trade_form = $("#tradeLotModal").data('show-action-form');
|
var show_trade_form = $("#tradeLotModal").data('show-action-form');
|
||||||
|
@ -71,9 +71,9 @@ function removeLot() {
|
||||||
|
|
||||||
function removeTag() {
|
function removeTag() {
|
||||||
var devices = $(".deviceSelect").filter(':checked');
|
var devices = $(".deviceSelect").filter(':checked');
|
||||||
var devices_id = $.map(devices, function (x) { return $(x).attr('data') });
|
var devices_id = $.map(devices, function(x) { return $(x).attr('data')});
|
||||||
if (devices_id.length == 1) {
|
if (devices_id.length == 1) {
|
||||||
var url = "/inventory/tag/devices/" + devices_id[0] + "/del/";
|
var url = "/inventory/tag/devices/"+devices_id[0]+"/del/";
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
} else {
|
} else {
|
||||||
$("#unlinkTagAlertModal").click();
|
$("#unlinkTagAlertModal").click();
|
||||||
|
@ -82,7 +82,7 @@ function removeTag() {
|
||||||
|
|
||||||
function addTag() {
|
function addTag() {
|
||||||
var devices = $(".deviceSelect").filter(':checked');
|
var devices = $(".deviceSelect").filter(':checked');
|
||||||
var devices_id = $.map(devices, function (x) { return $(x).attr('data') });
|
var devices_id = $.map(devices, function(x) { return $(x).attr('data')});
|
||||||
if (devices_id.length == 1) {
|
if (devices_id.length == 1) {
|
||||||
$("#addingTagModal .pol").hide();
|
$("#addingTagModal .pol").hide();
|
||||||
$("#addingTagModal .btn-primary").show();
|
$("#addingTagModal .btn-primary").show();
|
||||||
|
@ -146,8 +146,8 @@ function get_device_list() {
|
||||||
$("#actionModal .devices-count").html(devices_count);
|
$("#actionModal .devices-count").html(devices_count);
|
||||||
|
|
||||||
/* Insert the correct value in the input devicesList */
|
/* Insert the correct value in the input devicesList */
|
||||||
var devices_id = $.map(devices, function (x) { return $(x).attr('data') }).join(",");
|
var devices_id = $.map(devices, function(x) { return $(x).attr('data')}).join(",");
|
||||||
$.map($(".devicesList"), function (x) {
|
$.map($(".devicesList"), function(x) {
|
||||||
$(x).val(devices_id);
|
$(x).val(devices_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -166,15 +166,15 @@ function get_device_list() {
|
||||||
return typ + " " + manuf + " " + dhid;
|
return typ + " " + manuf + " " + dhid;
|
||||||
});
|
});
|
||||||
|
|
||||||
description = $.map(list_devices, function (x) { return x }).join(", ");
|
description = $.map(list_devices, function(x) { return x }).join(", ");
|
||||||
$(".enumeration-devices").html(description);
|
$(".enumeration-devices").html(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
function export_file(type_file) {
|
function export_file(type_file) {
|
||||||
var devices = $(".deviceSelect").filter(':checked');
|
var devices = $(".deviceSelect").filter(':checked');
|
||||||
var devices_id = $.map(devices, function (x) { return $(x).attr('data-device-dhid') }).join(",");
|
var devices_id = $.map(devices, function(x) { return $(x).attr('data-device-dhid')}).join(",");
|
||||||
if (devices_id) {
|
if (devices_id){
|
||||||
var url = "/inventory/export/" + type_file + "/?ids=" + devices_id;
|
var url = "/inventory/export/"+type_file+"/?ids="+devices_id;
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
} else {
|
} else {
|
||||||
$("#exportAlertModal").click();
|
$("#exportAlertModal").click();
|
||||||
|
@ -349,7 +349,7 @@ async function processSelectedDevices() {
|
||||||
this.notifyUser("Fail to remove devices from selected lot/s", error.responseJSON.message, true);
|
this.notifyUser("Fail to remove devices from selected lot/s", error.responseJSON.message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCount += 1
|
requestCount += 1
|
||||||
if (requestCount == this.list.length) {
|
if (requestCount == this.list.length) {
|
||||||
this.reRenderTable();
|
this.reRenderTable();
|
||||||
|
|
|
@ -299,7 +299,7 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" style="min-with: 14px">Select</th>
|
<th scope="col">Select</th>
|
||||||
<th scope="col">Title</th>
|
<th scope="col">Title</th>
|
||||||
<th scope="col">DHID</th>
|
<th scope="col">DHID</th>
|
||||||
<th scope="col">Tags</th>
|
<th scope="col">Tags</th>
|
||||||
|
@ -407,4 +407,4 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ url_for('static', filename='js/main_inventory.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/main_inventory.js') }}"></script>
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
|
|
Reference in a new issue