Commit 6ca90bec by François C.

Merge branch '#1925-ACL-multiple-down-key-cause-error' into 'dev_cooperatic'

1925 pressing multiple times on down arrow throw js error

See merge request !111
parents 46d9ed42 83db0aad
Pipeline #1746 passed with stage
in 1 minute 35 seconds
...@@ -29,7 +29,7 @@ var dbc = null, ...@@ -29,7 +29,7 @@ var dbc = null,
var clicked_order_pill = null; var clicked_order_pill = null;
var timerId
/* - UTILS */ /* - UTILS */
/** /**
...@@ -116,6 +116,11 @@ function _compute_stats_date_from() { ...@@ -116,6 +116,11 @@ function _compute_stats_date_from() {
return val; return val;
} }
function debounceFunction(func, delay = 1000) {
clearTimeout(timerId)
timerId = setTimeout(func, delay)
}
/* - PRODUCTS */ /* - PRODUCTS */
/** /**
...@@ -165,7 +170,7 @@ function add_product() { ...@@ -165,7 +170,7 @@ function add_product() {
res.default_code = ' '; res.default_code = ' ';
products.unshift(res); products.unshift(res);
update_main_screen({'sort_order_dir':'desc'}); update_main_screen({'sort_order_dir':'desc'});
update_cdb_order(); debounceFunction(update_cdb_order);
} else { } else {
alert("L'article n'a pas toutes les caractéristiques pour être ajouté."); alert("L'article n'a pas toutes les caractéristiques pour être ajouté.");
} }
...@@ -346,7 +351,7 @@ function update_product_ref(input_el, p_id, p_index) { ...@@ -346,7 +351,7 @@ function update_product_ref(input_el, p_id, p_index) {
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
data: JSON.stringify(data), data: JSON.stringify(data),
success: () => { success: () => {
update_cdb_order(); debounceFunction(update_cdb_order);
$(".actions_buttons_area .right_action_buttons").notify( $(".actions_buttons_area .right_action_buttons").notify(
"Référence sauvegardée !", "Référence sauvegardée !",
...@@ -424,7 +429,7 @@ function add_supplier() { ...@@ -424,7 +429,7 @@ function add_supplier() {
save_supplier_products(supplier, data.res.products); save_supplier_products(supplier, data.res.products);
update_main_screen(); update_main_screen();
$("#supplier_input").val(""); $("#supplier_input").val("");
update_cdb_order(); debounceFunction(update_cdb_order);
closeModal(); closeModal();
}, },
error: function(data) { error: function(data) {
...@@ -460,7 +465,7 @@ function remove_supplier(supplier_id) { ...@@ -460,7 +465,7 @@ function remove_supplier(supplier_id) {
products = products.filter(product => product.suppliersinfo.length > 0); products = products.filter(product => product.suppliersinfo.length > 0);
update_main_screen(); update_main_screen();
update_cdb_order(); debounceFunction(update_cdb_order);
} }
...@@ -527,7 +532,7 @@ function save_supplier_product_association(product, supplier, cell) { ...@@ -527,7 +532,7 @@ function save_supplier_product_association(product, supplier, cell) {
products_table.row(row).data(new_row_data) products_table.row(row).data(new_row_data)
.draw(); .draw();
update_cdb_order(); debounceFunction(update_cdb_order);
closeModal(); closeModal();
}, },
error: function(data) { error: function(data) {
...@@ -581,7 +586,7 @@ function end_supplier_product_association(product, supplier) { ...@@ -581,7 +586,7 @@ function end_supplier_product_association(product, supplier) {
// Update table // Update table
display_products(); display_products();
update_cdb_order(); debounceFunction(update_cdb_order);
closeModal(); closeModal();
}, },
error: function(data) { error: function(data) {
...@@ -716,6 +721,8 @@ function save_products_npa_minimal_stock(product, inputs) { ...@@ -716,6 +721,8 @@ function save_products_npa_minimal_stock(product, inputs) {
if (actions.npa.length > 0) { if (actions.npa.length > 0) {
// Remove NPA products // Remove NPA products
products.splice(index, 1); products.splice(index, 1);
update_main_screen();
debounceFunction(update_cdb_order);
} }
check_products_data() check_products_data()
...@@ -1166,7 +1173,7 @@ function goto_main_screen(doc) { ...@@ -1166,7 +1173,7 @@ function goto_main_screen(doc) {
check_products_data() check_products_data()
.then(() => { .then(() => {
update_cdb_order(); debounceFunction(update_cdb_order);
update_main_screen(); update_main_screen();
switch_screen(); switch_screen();
}); });
...@@ -1612,7 +1619,7 @@ function display_products(params) { ...@@ -1612,7 +1619,7 @@ function display_products(params) {
products_table.row($(this).closest('tr')).data(new_row_data) products_table.row($(this).closest('tr')).data(new_row_data)
.draw(); .draw();
update_cdb_order(); debounceFunction(update_cdb_order);
display_total_values(); display_total_values();
} else { } else {
$(this).val(''); $(this).val('');
...@@ -2106,7 +2113,7 @@ $(document).ready(function() { ...@@ -2106,7 +2113,7 @@ $(document).ready(function() {
if (!isNaN(val)) { if (!isNaN(val)) {
order_doc.coverage_days = val; order_doc.coverage_days = val;
compute_products_coverage_qties(); compute_products_coverage_qties();
update_cdb_order(); debounceFunction(update_cdb_order);
update_main_screen(); update_main_screen();
} else { } else {
$("#coverage_days_input").val(order_doc.coverage_days); $("#coverage_days_input").val(order_doc.coverage_days);
...@@ -2166,7 +2173,7 @@ $(document).ready(function() { ...@@ -2166,7 +2173,7 @@ $(document).ready(function() {
.then(() => { .then(() => {
compute_products_coverage_qties(); compute_products_coverage_qties();
update_main_screen(); update_main_screen();
update_cdb_order(); debounceFunction(update_cdb_order);
closeModal(); closeModal();
}); });
} }
...@@ -2183,7 +2190,7 @@ $(document).ready(function() { ...@@ -2183,7 +2190,7 @@ $(document).ready(function() {
openModal(); openModal();
check_products_data() check_products_data()
.then(() => { .then(() => {
update_cdb_order(); debounceFunction(update_cdb_order);
update_main_screen(); update_main_screen();
$("#toggle_action_buttons").click(); $("#toggle_action_buttons").click();
closeModal(); closeModal();
......
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