From 937bd6b702717e275cb71e0a20ce82a558ca5794 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 22 Dec 2020 19:06:41 +0100 Subject: [PATCH] Fixed camera scanning targets (fixes #1210) --- changelog/61_UNRELEASED_xxxx-xx-xx.md | 2 +- public/viewjs/barcodescannertesting.js | 2 +- public/viewjs/productbarcodeform.js | 10 ++++++++++ views/productbarcodeform.blade.php | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/changelog/61_UNRELEASED_xxxx-xx-xx.md b/changelog/61_UNRELEASED_xxxx-xx-xx.md index 0a56b5e9..0ef39715 100644 --- a/changelog/61_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/61_UNRELEASED_xxxx-xx-xx.md @@ -1,2 +1,2 @@ -### General & other improvements/fixes - Improved the prerequisites checker (added missing required PHP extension `ctype`) (thanks @Forceu) +- Fixed that browser camera barcode scanning did not work on the product edit page diff --git a/public/viewjs/barcodescannertesting.js b/public/viewjs/barcodescannertesting.js index 10d26dd1..bf630cbf 100644 --- a/public/viewjs/barcodescannertesting.js +++ b/public/viewjs/barcodescannertesting.js @@ -87,7 +87,7 @@ function OnBarcodeScanned(barcode) $(document).on("Grocy.BarcodeScanned", function(e, barcode, target) { - if (target !== "#scanned_barcod") + if (target !== "#scanned_barcode") { return; } diff --git a/public/viewjs/productbarcodeform.js b/public/viewjs/productbarcodeform.js index 02c7bb26..ece5e050 100644 --- a/public/viewjs/productbarcodeform.js +++ b/public/viewjs/productbarcodeform.js @@ -88,3 +88,13 @@ Grocy.FrontendHelpers.ValidateForm('barcode-form'); $('#barcode').focus(); RefreshLocaleNumberInput(); Grocy.Components.UserfieldsForm.Load() + +$(document).on("Grocy.BarcodeScanned", function(e, barcode, target) +{ + if (target !== "#barcode") + { + return; + } + + $("#barcode").val(barcode); +}); diff --git a/views/productbarcodeform.blade.php b/views/productbarcodeform.blade.php index fa1e2ff6..3089b9bc 100644 --- a/views/productbarcodeform.blade.php +++ b/views/productbarcodeform.blade.php @@ -58,7 +58,7 @@ id="barcode" name="barcode" value="@if($mode == 'edit'){{ $barcode->barcode }}@endif" - data-target="#scanned_barcode"> + data-target="#barcode"> @include('components.barcodescanner')