Commit e9b430ed by François C.

Merge branch '3381-press-enter-after-scanning-product' into 'dev_cooperatic'

INV: fix input focus when product scanned

See merge request !191
parents 8ceb9a83 5cd18d7b
Pipeline #2299 passed with stage
in 1 minute 24 seconds
......@@ -102,6 +102,7 @@ function barcode_analyzer(chars) {
} else {
//manually submitted after correction
var barcode_input = $('#search_input');
barcode = barcode_input.val();
}
......@@ -166,6 +167,7 @@ function select_product_from_bc(barcode) {
}
} else {
alert("Le code-barre " + barcode + " n'est pas reconnu comme un EAN13 ou EAN8 valide.");
return -1;
}
......@@ -314,6 +316,7 @@ function setLineEdition(item, qty) {
if (editing_origin == 'processed') {
edition_input.val(editing_item.qty);
}
if (set_focus === true)
edition_input.focus();
......@@ -394,9 +397,15 @@ function editProductInfo (productToEdit, value = null) {
var newValue = (value == null) ? parseFloat($('#edition_input').val()
.replace(',', '.')) : value;
if (isNaN(newValue)) {
alert("Veuillez rentrer une valeur valide dans le champ d'édition !");
return false;
}
// If uom is unit, prevent float
if (productToEdit.uom_id[0] == 1 && !Number.isSafeInteger(newValue)) {
alert('Vous ne pouvez pas rentrer de chiffre à virgule pour des produits à l\'unité');
alert('Vous ne pouvez pas rentrer de chiffre à virgule pour des produits à l\'unité.');
return false;
}
......@@ -861,6 +870,7 @@ function send() {
data: JSON.stringify(shelf),
success: function(data) {
let next_step_call = back;
// If step 1, display additionnal message in validation popup
if (shelf.inventory_status == '') {
inventory_validated_msg.find('#step1_validated').show();
......@@ -1220,13 +1230,6 @@ function init() {
$(this).off('wheel.disableScroll');
});
$("#edition_input").keypress(function(event) {
// Force validation when enter pressed in edition
if (event.keyCode == 13 || event.which == 13) {
validateEdition();
}
});
// client-side validation of numeric inputs, optionally replacing separator sign(s).
$("input.number").on("keydown", function (e) {
// allow function keys and decimal separators
......@@ -1278,6 +1281,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) {
e.stopPropagation(); // Prevent validation edition in this specific case
debounce(barcode_analyzer); // Avoid concurrent barcode analysing
}
});
......@@ -1332,4 +1336,14 @@ $(document).ready(function() {
}
get_barcodes();
/**
* Validate edition if enter pressed, wherever the focus is.
* validateEdition is triggered only if a product is in the edition area.
*/
$(document).keypress(function(event) {
if (event.keyCode == 13 || event.which == 13) {
validateEdition();
}
});
});
......@@ -417,7 +417,7 @@ var addProductToList = async function(barcode) {
$('<td>').html(delete_icon + " " + print_icon)
.appendTo(pdt_line);
adding_pdts_tpl.find('#added_products tbody').append(pdt_line);
main_content.find('.add-products').css('display', 'block')
main_content.find('.add-products').css('display', 'block');
}
}
};
......
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