From 9c9511b95ea60f32a124bb1c7917418f2605262c Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 27 Oct 2015 16:52:06 +0100 Subject: [PATCH] Add error when barcode not found --- app/assets/javascripts/orders.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/orders.js b/app/assets/javascripts/orders.js index d83c5ba..0c3d3a0 100644 --- a/app/assets/javascripts/orders.js +++ b/app/assets/javascripts/orders.js @@ -50,11 +50,16 @@ ready = function() { $("#from_barcode_form").submit(function(event) { event.preventDefault(); barcode = $(this).find("input[type=number]").val(); + $("#from_barcode_form")[0].reset(); $.ajax({ - url: "/tap/barcodes/" + barcode, + url: "/barcodes/" + barcode, success: function(data) { - increment_product(data["id"]); - $("#from_barcode_form")[0].reset(); + if (data != null) { + increment_product(data["id"]); + $("#from_barcode_form")[0].reset(); + } else { + alert("Barcode '" + barcode + "' was not found in the database system."); + } }, dataMethod: "json" }).fail(function() {