Commit 0ef1582e by Administrator

Merge branch '5524-SUPERCAFOUTCH-prevent-scan-while-focus-is-in-qty-input' into 'dev_cooperatic'

prevent using scan in qty inputs

See merge request !260
parents 422a6e0a ba58b323
Pipeline #3283 failed with stage
in 1 minute 4 seconds
...@@ -40,6 +40,8 @@ var dbc = null, ...@@ -40,6 +40,8 @@ var dbc = null,
sync = null, sync = null,
fingerprint = null; fingerprint = null;
let lastKeypressTime = 0;
/* UTILS */ /* UTILS */
function back() { function back() {
...@@ -2596,6 +2598,19 @@ function init_dom(partners_display_data) { ...@@ -2596,6 +2598,19 @@ function init_dom(partners_display_data) {
// Barcode reader // Barcode reader
$(document).pos(); $(document).pos();
$(document).on('keydown','#edition_input',function(event) {
const keypressTime = event.timeStamp;
const timeDifference = keypressTime - lastKeypressTime;
lastKeypressTime = keypressTime;
// Assuming a scanner would input faster than 50ms between keystrokes
if (timeDifference < 50) {
// Looks like scanner input, ignore or handle differently
event.preventDefault();
// You can display a message or handle the input differently
alert("Vous ne pouvez pas scanner pour saisir une quantité.");
}
});
$(document).on('scan.pos.barcode', function(event) { $(document).on('scan.pos.barcode', function(event) {
//access `event.code` - barcode data //access `event.code` - barcode data
var barcode = event.code; var barcode = event.code;
......
...@@ -35,6 +35,7 @@ var shelf = null, ...@@ -35,6 +35,7 @@ var shelf = null,
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; debounce_timeout = null;
let lastKeypressTime = 0;
/* UTILS */ /* UTILS */
...@@ -1241,6 +1242,19 @@ function init() { ...@@ -1241,6 +1242,19 @@ function init() {
}); });
$(document).pos(); $(document).pos();
$(document).on('keydown','#edition_input',function(event) {
const keypressTime = event.timeStamp;
const timeDifference = keypressTime - lastKeypressTime;
lastKeypressTime = keypressTime;
// Assuming a scanner would input faster than 50ms between keystrokes
if (timeDifference < 50) {
// Looks like scanner input, ignore or handle differently
event.preventDefault();
// You can display a message or handle the input differently
alert("Vous ne pouvez pas scanner pour saisir une quantité.");
}
});
$(document).on('scan.pos.barcode', function(event) { $(document).on('scan.pos.barcode', function(event) {
//access `event.code` - barcode data //access `event.code` - barcode data
var barcode = event.code; var barcode = event.code;
......
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