From 4bb9c4c5592b8da350e76997f7e2dccb1ecf7b5e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 11 Jun 2020 19:27:32 +1000 Subject: [PATCH] Prevent barcode data being entered multiple times --- .../InvenTree/static/script/inventree/barcode.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/barcode.js b/InvenTree/InvenTree/static/script/inventree/barcode.js index 0be3f0e9d6..f623a6e886 100644 --- a/InvenTree/InvenTree/static/script/inventree/barcode.js +++ b/InvenTree/InvenTree/static/script/inventree/barcode.js @@ -90,6 +90,15 @@ function clearBarcodeError(modal, message) { } +function enableBarcodeInput(modal, enabled=true) { + + var barcode = $(modal + ' #barcode'); + + barcode.prop('disabled', !enabled); + + modalEnable(modal, enabled); +} + function getBarcodeData(modal) { modal = modal || '#modal-form'; @@ -126,7 +135,6 @@ function barcodeDialog(title, options={}) { var barcode = getBarcodeData(modal); if (options.submit) { - modalEnable(modal, false); options.submit(barcode); } @@ -138,7 +146,6 @@ function barcodeDialog(title, options={}) { var barcode = getBarcodeData(modal); if (options.submit) { - modalEnable(modal, false); options.submit(barcode); } }); @@ -182,7 +189,9 @@ function barcodeScanDialog() { barcodeDialog( "Scan Barcode", { + headerContent: `
Scan barcode data below
`, submit: function(barcode) { + enableBarcodeInput(modal, false); inventreePut( '/api/barcode/', { @@ -194,6 +203,8 @@ function barcodeScanDialog() { console.log(response); + enableBarcodeInput(modal, true); + if (status == 'success') { if ('success' in response) {