diff --git a/public/js/grocy.js b/public/js/grocy.js
index ed57ac90..d03cbbe7 100644
--- a/public/js/grocy.js
+++ b/public/js/grocy.js
@@ -553,7 +553,7 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
return;
}
- $(this).text(parseFloat($(this).text()).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
+ $(this).text(parseFloat($(this).text()).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
});
$(rootSelector + " .locale-number.locale-number-quantity-amount").each(function()
@@ -578,6 +578,40 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
}
RefreshLocaleNumberDisplay();
+function RefreshLocaleNumberInput(rootSelector = "#page-content")
+{
+ $(rootSelector + " .locale-number-input.locale-number-currency").each(function()
+ {
+ if (isNaN(parseFloat($(this).val())))
+ {
+ return;
+ }
+
+ $(this).val(parseFloat($(this).val()).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
+ });
+
+ $(rootSelector + " .locale-number-input.locale-number-quantity-amount").each(function()
+ {
+ if (isNaN(parseFloat($(this).val())))
+ {
+ return;
+ }
+
+ $(this).val(parseFloat($(this).val()).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+ });
+
+ $(rootSelector + " .locale-number-input.locale-number-generic").each(function()
+ {
+ if (isNaN(parseFloat($(this).val())))
+ {
+ return;
+ }
+
+ $(this).val(parseFloat($(this).val()).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 }));
+ });
+}
+RefreshLocaleNumberInput();
+
$(document).on("click", ".easy-link-copy-textbox", function()
{
$(this).select();
diff --git a/public/viewjs/batteriessettings.js b/public/viewjs/batteriessettings.js
index 2dd30245..792c3d93 100644
--- a/public/viewjs/batteriessettings.js
+++ b/public/viewjs/batteriessettings.js
@@ -1 +1,3 @@
$("#batteries_due_soon_days").val(Grocy.UserSettings.batteries_due_soon_days);
+
+RefreshLocaleNumberInput();
diff --git a/public/viewjs/choressettings.js b/public/viewjs/choressettings.js
index 1b121a35..52967a6a 100644
--- a/public/viewjs/choressettings.js
+++ b/public/viewjs/choressettings.js
@@ -1 +1,3 @@
$("#chores_due_soon_days").val(Grocy.UserSettings.chores_due_soon_days);
+
+RefreshLocaleNumberInput();
diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js
index 07b04842..85f8ee40 100644
--- a/public/viewjs/consume.js
+++ b/public/viewjs/consume.js
@@ -97,6 +97,7 @@
$("#display_amount").attr("step", "1");
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '1'));
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$("#tare-weight-handling-info").addClass("d-none");
Grocy.Components.ProductPicker.Clear();
@@ -162,6 +163,7 @@ $('#save-mark-as-open-button').on('click', function(e)
toastr.success(__t('Marked %1$s of %2$s as opened', jsonForm.amount + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + __t("Undo") + '');
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.Components.ProductPicker.Clear();
Grocy.Components.ProductPicker.GetInputElement().focus();
@@ -275,6 +277,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_stock.id);
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$("#location_id").find("option").remove().end().append("");
@@ -312,6 +315,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
if (BoolVal(Grocy.UserSettings.scan_mode_consume_enabled))
{
$("#display_amount").val(1);
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm("consume-form");
diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js
index 6ce55e75..f7c27ee3 100644
--- a/public/viewjs/inventory.js
+++ b/public/viewjs/inventory.js
@@ -163,6 +163,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
}
$('#price').val(parseFloat(productDetails.last_price).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
+ RefreshLocaleNumberInput();
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
Grocy.Components.ShoppingLocationPicker.SetId(productDetails.last_shopping_location_id);
@@ -173,6 +174,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
}
$('#display_amount').val(productDetails.stock_amount);
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$('#display_amount').focus();
$('#display_amount').trigger('keyup');
diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js
index b12fd026..2e8ff1c6 100644
--- a/public/viewjs/mealplan.js
+++ b/public/viewjs/mealplan.js
@@ -777,6 +777,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
$('#display_amount').val(1);
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$('#display_amount').focus();
$('#display_amount').select();
diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js
index 88e2de1a..5898a1b0 100644
--- a/public/viewjs/productform.js
+++ b/public/viewjs/productform.js
@@ -256,6 +256,9 @@ $("#allow_partial_units_in_stock").on("click", function()
$("#qu_factor_purchase_to_stock").attr("min", "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
$("#qu_factor_purchase_to_stock").attr("step", "." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
$("#qu_factor_purchase_to_stock").parent().find(".invalid-feedback").text(__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1", Grocy.UserSettings.stock_decimal_places_amounts));
+ $("#quick_consume_amount").attr("min", "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
+ $("#quick_consume_amount").attr("step", "." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
+ $("#quick_consume_amount").parent().find(".invalid-feedback").text(__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1", Grocy.UserSettings.stock_decimal_places_amounts));
}
else
{
@@ -264,6 +267,9 @@ $("#allow_partial_units_in_stock").on("click", function()
$("#qu_factor_purchase_to_stock").attr("min", "1");
$("#qu_factor_purchase_to_stock").attr("step", "1");
$("#qu_factor_purchase_to_stock").parent().find(".invalid-feedback").text(__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '1', '0'));
+ $("#quick_consume_amount").attr("min", "1");
+ $("#quick_consume_amount").attr("step", "1");
+ $("#quick_consume_amount").parent().find(".invalid-feedback").text(__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '1', '0'));
}
Grocy.FrontendHelpers.ValidateForm("product-form");
diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js
index 2ca2745e..1237425f 100644
--- a/public/viewjs/purchase.js
+++ b/public/viewjs/purchase.js
@@ -204,7 +204,15 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.Components.LocationPicker.SetId(productDetails.location.id);
}
- $('#price').val(parseFloat(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor")).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
+ if (productDetails.last_price == null)
+ {
+ $("#price").val("")
+ }
+ else
+ {
+ $('#price').val(parseFloat(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor")).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
+ RefreshLocaleNumberInput();
+ }
var priceTypeUnitPrice = $("#price-type-unit-price");
var priceTypeUnitPriceLabel = $("[for=" + priceTypeUnitPrice.attr("id") + "]");
@@ -267,6 +275,7 @@ if (Grocy.Components.ProductPicker !== undefined)
if (BoolVal(Grocy.UserSettings.scan_mode_purchase_enabled))
{
$("#display_amount").val(1);
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm("purchase-form");
@@ -332,6 +341,7 @@ if (Grocy.Components.ProductPicker !== undefined)
}
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('purchase-form');
diff --git a/public/viewjs/recipessettings.js b/public/viewjs/recipessettings.js
index e59593bd..9b67918b 100644
--- a/public/viewjs/recipessettings.js
+++ b/public/viewjs/recipessettings.js
@@ -2,3 +2,5 @@
{
$("#recipe_ingredients_group_by_product_group").prop("checked", true);
}
+
+RefreshLocaleNumberInput();
diff --git a/public/viewjs/shoppinglistitemform.js b/public/viewjs/shoppinglistitemform.js
index e2d78275..d806b2df 100644
--- a/public/viewjs/shoppinglistitemform.js
+++ b/public/viewjs/shoppinglistitemform.js
@@ -212,6 +212,7 @@ if (GetUriParam("list") !== undefined)
if (GetUriParam("amount") !== undefined)
{
$("#display_amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
}
diff --git a/public/viewjs/shoppinglistsettings.js b/public/viewjs/shoppinglistsettings.js
index 68460c61..6f39c600 100644
--- a/public/viewjs/shoppinglistsettings.js
+++ b/public/viewjs/shoppinglistsettings.js
@@ -7,3 +7,5 @@ if (BoolVal(Grocy.UserSettings.shopping_list_show_calendar))
{
$("#shopping-list-show-calendar").prop("checked", true);
}
+
+RefreshLocaleNumberInput();
diff --git a/public/viewjs/stockentryform.js b/public/viewjs/stockentryform.js
index 96181f50..44e7deed 100644
--- a/public/viewjs/stockentryform.js
+++ b/public/viewjs/stockentryform.js
@@ -109,6 +109,8 @@ Grocy.Api.Get('stock/products/' + Grocy.EditObjectProductId,
$("#amount").attr("step", "1");
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', '1'));
}
+
+ RefreshLocaleNumberInput();
},
function(xhr)
{
diff --git a/public/viewjs/stocksettings.js b/public/viewjs/stocksettings.js
index 48497f43..5b4b140c 100644
--- a/public/viewjs/stocksettings.js
+++ b/public/viewjs/stocksettings.js
@@ -20,3 +20,5 @@ if (BoolVal(Grocy.UserSettings.show_warning_on_purchase_when_best_before_date_is
{
$("#show_warning_on_purchase_when_best_before_date_is_earlier_than_next").prop("checked", true);
}
+
+RefreshLocaleNumberInput();
diff --git a/public/viewjs/taskssettings.js b/public/viewjs/taskssettings.js
index 0980369a..c9cf81d3 100644
--- a/public/viewjs/taskssettings.js
+++ b/public/viewjs/taskssettings.js
@@ -1 +1,3 @@
$("#tasks_due_soon_days").val(Grocy.UserSettings.tasks_due_soon_days);
+
+RefreshLocaleNumberInput();
diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js
index 13d45016..153cde6a 100644
--- a/public/viewjs/transfer.js
+++ b/public/viewjs/transfer.js
@@ -94,6 +94,7 @@
$("#display_amount").attr("step", "1");
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '1'));
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_transfer_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
+ RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$("#tare-weight-handling-info").addClass("d-none");
Grocy.Components.ProductPicker.Clear();
diff --git a/public/viewjs/usersettings.js b/public/viewjs/usersettings.js
index 068b43cb..1d5d2635 100644
--- a/public/viewjs/usersettings.js
+++ b/public/viewjs/usersettings.js
@@ -1 +1,3 @@
$("#locale").val(Grocy.UserSettings.locale);
+
+RefreshLocaleNumberInput();
diff --git a/views/choreform.blade.php b/views/choreform.blade.php
index 18a9cdc9..4e527a30 100644
--- a/views/choreform.blade.php
+++ b/views/choreform.blade.php
@@ -260,7 +260,8 @@
'decimals' => $userSettings['stock_decimal_places_amounts'],
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'isRequired' => false,
- 'value' => $value
+ 'value' => $value,
+ 'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
))
@endif
diff --git a/views/components/productamountpicker.blade.php b/views/components/productamountpicker.blade.php
index e59992dd..c47aa59b 100644
--- a/views/components/productamountpicker.blade.php
+++ b/views/components/productamountpicker.blade.php
@@ -23,7 +23,7 @@
'value' => $value,
'invalidFeedback' => $__t('This cannot be negative and must be an integral number'),
'additionalGroupCssClasses' => 'col-sm-5 col-xs-12 my-0',
- 'additionalCssClasses' => 'input-group-productamountpicker',
+ 'additionalCssClasses' => 'input-group-productamountpicker locale-number-input locale-number-quantity-amount',
'additionalHtmlContextHelp' => '',
'additionalHtmlElements' => ''
))
diff --git a/views/inventory.blade.php b/views/inventory.blade.php
index 1486fe72..71361f9e 100644
--- a/views/inventory.blade.php
+++ b/views/inventory.blade.php
@@ -90,7 +90,8 @@
data-toggle="tooltip"
title="' . $__t('This will apply to added products') . '">',
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
- 'isRequired' => false
+ 'isRequired' => false,
+ 'additionalCssClasses' => 'locale-number-input locale-number-currency'
))
@include('components.shoppinglocationpicker', array(
diff --git a/views/mealplan.blade.php b/views/mealplan.blade.php
index 924a28d1..2798dad4 100644
--- a/views/mealplan.blade.php
+++ b/views/mealplan.blade.php
@@ -65,7 +65,8 @@
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
'decimals' => $userSettings['stock_decimal_places_amounts'],
'value' => '1',
- 'invalidFeedback' => $__t('This cannot be lower than %s', '1')
+ 'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
+ 'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
))
$userSettings['stock_decimal_places_amounts'],
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
- 'additionalGroupCssClasses' => 'mb-1'
+ 'additionalGroupCssClasses' => 'mb-1',
+ 'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
))