Prevent barcode data being entered multiple times

This commit is contained in:
Oliver Walters 2020-06-11 19:27:32 +10:00
parent 2d9b75c6ae
commit 4bb9c4c559

View File

@ -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) { function getBarcodeData(modal) {
modal = modal || '#modal-form'; modal = modal || '#modal-form';
@ -126,7 +135,6 @@ function barcodeDialog(title, options={}) {
var barcode = getBarcodeData(modal); var barcode = getBarcodeData(modal);
if (options.submit) { if (options.submit) {
modalEnable(modal, false);
options.submit(barcode); options.submit(barcode);
} }
@ -138,7 +146,6 @@ function barcodeDialog(title, options={}) {
var barcode = getBarcodeData(modal); var barcode = getBarcodeData(modal);
if (options.submit) { if (options.submit) {
modalEnable(modal, false);
options.submit(barcode); options.submit(barcode);
} }
}); });
@ -182,7 +189,9 @@ function barcodeScanDialog() {
barcodeDialog( barcodeDialog(
"Scan Barcode", "Scan Barcode",
{ {
headerContent: `<div class='alert alert-info alert-block'>Scan barcode data below</div>`,
submit: function(barcode) { submit: function(barcode) {
enableBarcodeInput(modal, false);
inventreePut( inventreePut(
'/api/barcode/', '/api/barcode/',
{ {
@ -194,6 +203,8 @@ function barcodeScanDialog() {
console.log(response); console.log(response);
enableBarcodeInput(modal, true);
if (status == 'success') { if (status == 'success') {
if ('success' in response) { if ('success' in response) {