From 96209c852cbfb1a5c135196a26e5537c69d07073 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 21 Apr 2017 22:50:16 +0200 Subject: [PATCH] Add flow to add a new product with prefilled barcode --- version.txt | 2 +- views/inventory.js | 14 ++++++++++++++ views/productform.js | 7 +++++++ views/purchase.js | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 1cc5f657..867e5243 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.2.0 \ No newline at end of file diff --git a/views/inventory.js b/views/inventory.js index 6c128619..4c341713 100644 --- a/views/inventory.js +++ b/views/inventory.js @@ -134,6 +134,8 @@ $(function() message: '' + input + ' could not be resolved to a product, how do you want to proceed?', title: 'Create or assign product', onEscape: function() { }, + size: 'large', + backdrop: true, buttons: { cancel: { label: 'Cancel', @@ -155,6 +157,14 @@ $(function() { window.location.href = '/inventory?addbarcodetoselection=' + encodeURIComponent(input); } + }, + addnewproductwithbarcode: { + label: 'Add as new product + prefill barcode', + className: 'btn-warning add-new-product-with-barcode-dialog-button', + callback: function() + { + window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname); + } } } }).on('keypress', function(e) @@ -167,6 +177,10 @@ $(function() { $('.add-new-product-dialog-button').click(); } + if (e.key === 'a' || e.key === 'A') + { + $('.add-new-product-with-barcode-dialog-button').click(); + } }); } } diff --git a/views/productform.js b/views/productform.js index 8e7c1b96..4cb46000 100644 --- a/views/productform.js +++ b/views/productform.js @@ -75,6 +75,13 @@ $(function() $('#name').val(prefillName); $('#name').focus(); } + + var prefillBarcode = Grocy.GetUriParam('prefillbarcode'); + if (prefillBarcode !== undefined) + { + $('#barcode-taginput').tagsManager('pushTag', prefillBarcode); + $('#name').focus(); + } }); $('.input-group-qu').on('change', function(e) diff --git a/views/purchase.js b/views/purchase.js index 51dc2fa5..24f5f08c 100644 --- a/views/purchase.js +++ b/views/purchase.js @@ -139,6 +139,8 @@ $(function() message: '' + input + ' could not be resolved to a product, how do you want to proceed?', title: 'Create or assign product', onEscape: function() { }, + size: 'large', + backdrop: true, buttons: { cancel: { label: 'Cancel', @@ -160,6 +162,14 @@ $(function() { window.location.href = '/purchase?addbarcodetoselection=' + encodeURIComponent(input); } + }, + addnewproductwithbarcode: { + label: 'Add as new product + prefill barcode', + className: 'btn-warning add-new-product-with-barcode-dialog-button', + callback: function() + { + window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname); + } } } }).on('keypress', function(e) @@ -172,6 +182,10 @@ $(function() { $('.add-new-product-dialog-button').click(); } + if (e.key === 'a' || e.key === 'A') + { + $('.add-new-product-with-barcode-dialog-button').click(); + } }); } }