@@ -92,6 +95,9 @@ function onBarcodeScanCompleted(result, options) {
postBarcodeData(result.data, options);
}
+/*
+ * Construct a generic "notes" field for barcode scanning operations
+ */
function makeNotesField(options={}) {
var tooltip = options.tooltip || '{% trans "Enter optional notes for stock transfer" %}';
@@ -199,6 +205,9 @@ function showBarcodeMessage(modal, message, style='danger') {
}
+/*
+ * Display an error message when the server indicates an error
+ */
function showInvalidResponseError(modal, response, status) {
showBarcodeMessage(
modal,
@@ -207,6 +216,9 @@ function showInvalidResponseError(modal, response, status) {
}
+/*
+ * Enable (or disable) the barcode scanning input
+ */
function enableBarcodeInput(modal, enabled=true) {
var barcode = $(modal + ' #barcode');
@@ -218,6 +230,10 @@ function enableBarcodeInput(modal, enabled=true) {
barcode.focus();
}
+
+/*
+ * Extract scanned data from the barcode input
+ */
function getBarcodeData(modal) {
modal = modal || '#modal-form';
@@ -233,10 +249,10 @@ function getBarcodeData(modal) {
}
+/*
+ * Handle a barcode display dialog.
+ */
function barcodeDialog(title, options={}) {
- /*
- * Handle a barcode display dialog.
- */
var modal = '#modal-form';
@@ -244,7 +260,6 @@ function barcodeDialog(title, options={}) {
var barcode = getBarcodeData(modal);
if (barcode && barcode.length > 0) {
-
postBarcodeData(barcode, options);
}
}
@@ -264,7 +279,15 @@ function barcodeDialog(title, options={}) {
event.preventDefault();
if (event.which == 10 || event.which == 13) {
+ clearTimeout(barcodeInputTimer);
sendBarcode();
+ } else {
+ // Start a timer to automatically send barcode after input is complete
+ clearTimeout(barcodeInputTimer);
+
+ barcodeInputTimer = setTimeout(function() {
+ sendBarcode();
+ }, global_settings.BARCODE_INPUT_DELAY);
}
});
@@ -305,9 +328,11 @@ function barcodeDialog(title, options={}) {
modalShowSubmitButton(modal, false);
}
+ var details = options.details || '{% trans "Scan barcode data" %}';
+
var content = '';
- content += `
{% trans "Scan barcode data below" %}
`;
+ content += `
${details}
`;
content += `
`;
content += `