diff --git a/changelog/56_UNRELEASED_2020-xx-xx.md b/changelog/56_UNRELEASED_2020-xx-xx.md index cf886726..e3e1d20a 100644 --- a/changelog/56_UNRELEASED_2020-xx-xx.md +++ b/changelog/56_UNRELEASED_2020-xx-xx.md @@ -17,4 +17,5 @@ ### General & other improvements/fixes - Optimized the top navbar height to waste less space +- Replaced the scan-mode-switch-button by a native button because it's less disturbing - Fixed that the "contextual time ago" of date/time pickers was not displayed diff --git a/package.json b/package.json index afb5c808..9450f4a2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "bootbox": "^5.3.2", "bootstrap": "^4.3.1", "bootstrap-select": "^1.13.10", - "bootstrap-switch-button": "https://github.com/walidbagh/bootstrap-switch-button#Fix-module-export", "chart.js": "^2.8.0", "datatables.net": "^1.10.19", "datatables.net-bs4": "^1.10.19", diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 70f622d3..0994434c 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -521,10 +521,6 @@ if (GetUriParam("embedded") !== undefined) // Default input field Grocy.Components.ProductPicker.GetInputElement().focus(); -// Can only be set via JS however... -$("#scan-mode").addClass("user-setting-control"); -$("#scan-mode").attr("data-setting-key", "scan_mode_consume_enabled"); - $(document).on("change", "#scan-mode", function(e) { if ($(this).prop("checked")) @@ -532,3 +528,18 @@ $(document).on("change", "#scan-mode", function(e) Grocy.UISound.AskForPermission(); } }); + +$("#scan-mode-button").on("click", function(e) +{ + document.activeElement.blur(); + $("#scan-mode").click(); + $("#scan-mode-button").toggleClass("btn-success").toggleClass("btn-danger"); + if ($("#scan-mode").prop("checked")) + { + $("#scan-mode-status").text(__t("on")); + } + else + { + $("#scan-mode-status").text(__t("off")); + } +}); diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index a5918903..91dcc3db 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -362,14 +362,25 @@ function UndoStockTransaction(transactionId) ); }; -// Can only be set via JS however... -$("#scan-mode").addClass("user-setting-control"); -$("#scan-mode").attr("data-setting-key", "scan_mode_purchase_enabled"); - -$(document).on("change", "#scan-mode", function(e) +$("#scan-mode").on("change", function(e) { if ($(this).prop("checked")) { Grocy.UISound.AskForPermission(); } }); + +$("#scan-mode-button").on("click", function(e) +{ + document.activeElement.blur(); + $("#scan-mode").click(); + $("#scan-mode-button").toggleClass("btn-success").toggleClass("btn-danger"); + if ($("#scan-mode").prop("checked")) + { + $("#scan-mode-status").text(__t("on")); + } + else + { + $("#scan-mode-status").text(__t("off")); + } +}); diff --git a/views/consume.blade.php b/views/consume.blade.php index e47e8e16..3f96f209 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -4,12 +4,7 @@ @section('activeNav', 'consume') @section('viewJsName', 'consume') -@push('pageStyles') - -@endpush - @push('pageScripts') - @endpush @@ -19,7 +14,8 @@