Commit 9afd5f37 by François C.

Merge branch '3124-inv-scan-product-not-found' into 'dev_cooperatic'

fix bug bipping a product not in shelf

See merge request !179
parents 05ba2c3d b01f1a25
Pipeline #2221 passed with stage
in 1 minute 45 seconds
......@@ -32,7 +32,8 @@ var shelf = null,
// datetime for which shelf's ongoing_inv_start_datetime is considered null
default_inventory_start_datetime = "0001-01-01 00:00:00",
selected_products_for_shelf_change = [],
all_shelfs = null; // Use get_all_shelfs to access it's value
all_shelfs = null, // Use get_all_shelfs to access it's value
debounce_timeout = null;
/* UTILS */
......@@ -56,6 +57,11 @@ function back() {
document.location.href = parent_location;
}
function debounce(func, delay = 100) {
clearTimeout(debounce_timeout);
debounce_timeout = setTimeout(func, delay);
}
function get_added_qties_sum(item) {
let total = null;
......@@ -109,6 +115,8 @@ function barcode_analyzer(chars) {
} else {
select_product_from_bc(barcode);
}
search_chars = [];
}
/**
......@@ -198,6 +206,7 @@ function select_product_from_bc(barcode) {
}
} else {
console.log('Code barre introuvable');
alert("Le produit bippé n'est pas enregistré dans ce rayon.");
}
} else if (barcode == editing_item.barcode && qty) {
// We scan the same product as the current one
......@@ -211,6 +220,8 @@ function select_product_from_bc(barcode) {
editing_item.qty = get_added_qties_sum(editing_item);
edition_input.val(editing_item.qty);
}
return null;
}
/*
......@@ -567,7 +578,7 @@ function initLists() {
</div>`,
className: "dt-body-center",
orderable: false,
render: function (data) {
render: function () {
return `<input type="checkbox" class="select_product_cb" />`;
},
width: "4%"});
......@@ -1247,7 +1258,7 @@ function init() {
if (e.which >= 48 && e.which <= 57) { // figures [0-9]
search_chars.push(String.fromCharCode(e.which));
} else if (e.which == 13 || search_chars.length >= 13) {
barcode_analyzer();
debounce(barcode_analyzer); // Avoid concurrent barcode analysing
}
});
......@@ -1256,8 +1267,7 @@ function init() {
//access `event.code` - barcode data
var barcode = event.code;
barcode_analyzer(barcode);
debounce(() => barcode_analyzer(barcode)); // Avoid concurrent barcode analysing
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment