From 2633d3d1a5e497a009d7aa98f18dda71c66bc333 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 22 May 2023 22:33:36 +0200 Subject: [PATCH] Fixed stock entry label info handling when the corresponding feature flag is disabled --- public/viewjs/inventory.js | 25 ++++++++++++++----------- public/viewjs/purchase.js | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index e4054795..c7f57e80 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -523,22 +523,25 @@ function UndoStockTransaction(transactionId) $("#display_amount").attr("min", "0"); -$("#stock_label_type, #amount").on("change", function(e) +if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER) { - if ($("#stock_label_type").val() == 2) + $("#stock_label_type, #amount").on("change", function(e) { - var estimatedBookingAmount = Number.parseFloat($("#amount").attr("data-estimated-booking-amount")); - if (estimatedBookingAmount > 0) + if ($("#stock_label_type").val() == 2) { - $("#stock-entry-label-info").text(__n(estimatedBookingAmount, "This means 1 label will be printed", "This means %1$s labels will be printed")); + var estimatedBookingAmount = Number.parseFloat($("#amount").attr("data-estimated-booking-amount")); + if (estimatedBookingAmount > 0) + { + $("#stock-entry-label-info").text(__n(estimatedBookingAmount, "This means 1 label will be printed", "This means %1$s labels will be printed")); + } + else + { + $("#stock-entry-label-info").text(""); + } } else { $("#stock-entry-label-info").text(""); } - } - else - { - $("#stock-entry-label-info").text(""); - } -}); + }); +} diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 63123b21..9f6f70f2 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -721,14 +721,17 @@ function ScanModeSubmit(singleUnit = true) } } -$("#stock_label_type, #amount").on("change", function(e) +if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER) { - if ($("#stock_label_type").val() == 2) + $("#stock_label_type, #amount").on("change", function(e) { - $("#stock-entry-label-info").text(__n(Number.parseFloat($("#amount").val()), "This means 1 label will be printed", "This means %1$s labels will be printed")); - } - else - { - $("#stock-entry-label-info").text(""); - } -}); + if ($("#stock_label_type").val() == 2) + { + $("#stock-entry-label-info").text(__n(Number.parseFloat($("#amount").val()), "This means 1 label will be printed", "This means %1$s labels will be printed")); + } + else + { + $("#stock-entry-label-info").text(""); + } + }); +}