Improved number input initial value decimal handling

This commit is contained in:
Bernd Bestel 2020-11-15 14:15:09 +01:00
parent 1d1642b464
commit 4b342dbd43
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
29 changed files with 111 additions and 21 deletions

View File

@ -553,7 +553,7 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
return; 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() $(rootSelector + " .locale-number.locale-number-quantity-amount").each(function()
@ -578,6 +578,40 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
} }
RefreshLocaleNumberDisplay(); 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() $(document).on("click", ".easy-link-copy-textbox", function()
{ {
$(this).select(); $(this).select();

View File

@ -1 +1,3 @@
$("#batteries_due_soon_days").val(Grocy.UserSettings.batteries_due_soon_days); $("#batteries_due_soon_days").val(Grocy.UserSettings.batteries_due_soon_days);
RefreshLocaleNumberInput();

View File

@ -1 +1,3 @@
$("#chores_due_soon_days").val(Grocy.UserSettings.chores_due_soon_days); $("#chores_due_soon_days").val(Grocy.UserSettings.chores_due_soon_days);
RefreshLocaleNumberInput();

View File

@ -97,6 +97,7 @@
$("#display_amount").attr("step", "1"); $("#display_amount").attr("step", "1");
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '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 })); $('#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"); $(".input-group-productamountpicker").trigger("change");
$("#tare-weight-handling-info").addClass("d-none"); $("#tare-weight-handling-info").addClass("d-none");
Grocy.Components.ProductPicker.Clear(); 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) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>'); 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) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })); $('#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"); $(".input-group-productamountpicker").trigger("change");
Grocy.Components.ProductPicker.Clear(); Grocy.Components.ProductPicker.Clear();
Grocy.Components.ProductPicker.GetInputElement().focus(); 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.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
Grocy.Components.ProductAmountPicker.SetQuantityUnit(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 })); $('#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"); $(".input-group-productamountpicker").trigger("change");
$("#location_id").find("option").remove().end().append("<option></option>"); $("#location_id").find("option").remove().end().append("<option></option>");
@ -312,6 +315,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
if (BoolVal(Grocy.UserSettings.scan_mode_consume_enabled)) if (BoolVal(Grocy.UserSettings.scan_mode_consume_enabled))
{ {
$("#display_amount").val(1); $("#display_amount").val(1);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change"); $(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm("consume-form"); Grocy.FrontendHelpers.ValidateForm("consume-form");

View File

@ -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 })); $('#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) if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{ {
Grocy.Components.ShoppingLocationPicker.SetId(productDetails.last_shopping_location_id); 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); $('#display_amount').val(productDetails.stock_amount);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change"); $(".input-group-productamountpicker").trigger("change");
$('#display_amount').focus(); $('#display_amount').focus();
$('#display_amount').trigger('keyup'); $('#display_amount').trigger('keyup');

View File

@ -777,6 +777,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id); Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
$('#display_amount').val(1); $('#display_amount').val(1);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change"); $(".input-group-productamountpicker").trigger("change");
$('#display_amount').focus(); $('#display_amount').focus();
$('#display_amount').select(); $('#display_amount').select();

View File

@ -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("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").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)); $("#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 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("min", "1");
$("#qu_factor_purchase_to_stock").attr("step", "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')); $("#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"); Grocy.FrontendHelpers.ValidateForm("product-form");

View File

@ -204,7 +204,15 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.Components.LocationPicker.SetId(productDetails.location.id); Grocy.Components.LocationPicker.SetId(productDetails.location.id);
} }
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 })); $('#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 priceTypeUnitPrice = $("#price-type-unit-price");
var priceTypeUnitPriceLabel = $("[for=" + priceTypeUnitPrice.attr("id") + "]"); var priceTypeUnitPriceLabel = $("[for=" + priceTypeUnitPrice.attr("id") + "]");
@ -267,6 +275,7 @@ if (Grocy.Components.ProductPicker !== undefined)
if (BoolVal(Grocy.UserSettings.scan_mode_purchase_enabled)) if (BoolVal(Grocy.UserSettings.scan_mode_purchase_enabled))
{ {
$("#display_amount").val(1); $("#display_amount").val(1);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change"); $(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm("purchase-form"); 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 })); $('#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"); $(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('purchase-form'); Grocy.FrontendHelpers.ValidateForm('purchase-form');

View File

@ -2,3 +2,5 @@
{ {
$("#recipe_ingredients_group_by_product_group").prop("checked", true); $("#recipe_ingredients_group_by_product_group").prop("checked", true);
} }
RefreshLocaleNumberInput();

View File

@ -212,6 +212,7 @@ if (GetUriParam("list") !== undefined)
if (GetUriParam("amount") !== undefined) if (GetUriParam("amount") !== undefined)
{ {
$("#display_amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })); $("#display_amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change"); $(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form'); Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
} }

View File

@ -7,3 +7,5 @@ if (BoolVal(Grocy.UserSettings.shopping_list_show_calendar))
{ {
$("#shopping-list-show-calendar").prop("checked", true); $("#shopping-list-show-calendar").prop("checked", true);
} }
RefreshLocaleNumberInput();

View File

@ -109,6 +109,8 @@ Grocy.Api.Get('stock/products/' + Grocy.EditObjectProductId,
$("#amount").attr("step", "1"); $("#amount").attr("step", "1");
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', '1')); $("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', '1'));
} }
RefreshLocaleNumberInput();
}, },
function(xhr) function(xhr)
{ {

View File

@ -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); $("#show_warning_on_purchase_when_best_before_date_is_earlier_than_next").prop("checked", true);
} }
RefreshLocaleNumberInput();

View File

@ -1 +1,3 @@
$("#tasks_due_soon_days").val(Grocy.UserSettings.tasks_due_soon_days); $("#tasks_due_soon_days").val(Grocy.UserSettings.tasks_due_soon_days);
RefreshLocaleNumberInput();

View File

@ -94,6 +94,7 @@
$("#display_amount").attr("step", "1"); $("#display_amount").attr("step", "1");
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '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 })); $('#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"); $(".input-group-productamountpicker").trigger("change");
$("#tare-weight-handling-info").addClass("d-none"); $("#tare-weight-handling-info").addClass("d-none");
Grocy.Components.ProductPicker.Clear(); Grocy.Components.ProductPicker.Clear();

View File

@ -1 +1,3 @@
$("#locale").val(Grocy.UserSettings.locale); $("#locale").val(Grocy.UserSettings.locale);
RefreshLocaleNumberInput();

View File

@ -260,7 +260,8 @@
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'), 'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'isRequired' => false, 'isRequired' => false,
'value' => $value 'value' => $value,
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
@endif @endif

View File

@ -23,7 +23,7 @@
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('This cannot be negative and must be an integral number'), 'invalidFeedback' => $__t('This cannot be negative and must be an integral number'),
'additionalGroupCssClasses' => 'col-sm-5 col-xs-12 my-0', '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' => '', 'additionalHtmlContextHelp' => '',
'additionalHtmlElements' => '' 'additionalHtmlElements' => ''
)) ))

View File

@ -90,7 +90,8 @@
data-toggle="tooltip" data-toggle="tooltip"
title="' . $__t('This will apply to added products') . '"></i>', title="' . $__t('This will apply to added products') . '"></i>',
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'), '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( @include('components.shoppinglocationpicker', array(

View File

@ -65,7 +65,8 @@
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1', 'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'value' => '1', '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'
)) ))
<input type="hidden" <input type="hidden"

View File

@ -146,7 +146,8 @@
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'), 'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'additionalGroupCssClasses' => 'mb-1' 'additionalGroupCssClasses' => 'mb-1',
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
<div class="form-group"> <div class="form-group">
@ -251,7 +252,7 @@
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'), 'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalCssClasses' => 'input-group-qu', 'additionalCssClasses' => 'input-group-qu locale-number-input locale-number-quantity-amount',
'additionalHtmlElements' => '<p id="qu-conversion-info" 'additionalHtmlElements' => '<p id="qu-conversion-info"
class="form-text text-info d-none"></p>' class="form-text text-info d-none"></p>'
)) ))
@ -290,7 +291,8 @@
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %s', '0'), 'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
'additionalAttributes' => $additionalAttributes, 'additionalAttributes' => $additionalAttributes,
'contextInfoId' => 'tare_weight_qu_info' 'contextInfoId' => 'tare_weight_qu_info',
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
@php $additionalAttributes = '' @endphp @php $additionalAttributes = '' @endphp
@ -318,7 +320,8 @@
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'), 'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'hint' => $__t('Per stock quantity unit'), 'hint' => $__t('Per stock quantity unit'),
'isRequired' => false 'isRequired' => false,
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
@endif @endif
@ -359,7 +362,8 @@
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'), 'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'hint' => $__t('This amount is used for the "quick consume/open buttons" on the stock overview page (related to quantity unit stock)'), 'hint' => $__t('This amount is used for the "quick consume/open buttons" on the stock overview page (related to quantity unit stock)'),
'contextInfoId' => 'quick_consume_qu_info' 'contextInfoId' => 'quick_consume_qu_info',
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
@include('components.userfieldsform', array( @include('components.userfieldsform', array(

View File

@ -107,7 +107,8 @@
'contextInfoId' => 'price-hint', 'contextInfoId' => 'price-hint',
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'), 'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
'isRequired' => false, 'isRequired' => false,
'additionalGroupCssClasses' => 'mb-1' 'additionalGroupCssClasses' => 'mb-1',
'additionalCssClasses' => 'locale-number-input locale-number-currency'
)) ))
<div class="form-check form-check-inline mb-3"> <div class="form-check form-check-inline mb-3">

View File

@ -91,7 +91,7 @@
'invalidFeedback' => $__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '0', $userSettings['stock_decimal_places_amounts']), 'invalidFeedback' => $__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '0', $userSettings['stock_decimal_places_amounts']),
'additionalHtmlElements' => '<p id="qu-conversion-info" 'additionalHtmlElements' => '<p id="qu-conversion-info"
class="form-text text-info d-none"></p>', class="form-text text-info d-none"></p>',
'additionalCssClasses' => 'input-group-qu' 'additionalCssClasses' => 'input-group-qu locale-number-input locale-number-quantity-amount'
)) ))
<div class="form-group @if($mode == 'edit') d-none @endif"> <div class="form-group @if($mode == 'edit') d-none @endif">

View File

@ -43,7 +43,8 @@
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1', 'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'isRequired' => false, 'isRequired' => false,
'value' => 1 'value' => 1,
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
</form> </form>

View File

@ -69,7 +69,8 @@
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'value' => $value, 'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %s', '1'), 'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'hint' => $__t('The ingredients listed here result in this amount of servings') 'hint' => $__t('The ingredients listed here result in this amount of servings'),
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
<div class="form-group"> <div class="form-group">
@ -364,7 +365,8 @@
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1', 'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'value' => '1', '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'
)) ))
</form> </form>

View File

@ -115,7 +115,8 @@
'hint' => $__t('The resulting price of this ingredient will be multiplied by this factor'), 'hint' => $__t('The resulting price of this ingredient will be multiplied by this factor'),
'invalidFeedback' => $__t('This cannot be lower than %s', '0'), 'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
'isRequired' => true, 'isRequired' => true,
'value' => $value 'value' => $value,
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
@else @else
<input type="hidden" <input type="hidden"

View File

@ -335,7 +335,8 @@
'value' => $recipe->desired_servings, 'value' => $recipe->desired_servings,
'invalidFeedback' => $__t('This cannot be lower than %s', '1'), 'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalAttributes' => 'data-recipe-id="' . $recipe->id . '"', 'additionalAttributes' => 'data-recipe-id="' . $recipe->id . '"',
'hint' => $__t('Base: %s', $recipe->base_servings) 'hint' => $__t('Base: %s', $recipe->base_servings),
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
</div> </div>
@endif @endif

View File

@ -60,6 +60,7 @@
'contextInfoId' => 'amount_qu_unit', 'contextInfoId' => 'amount_qu_unit',
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'), 'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'additionalAttributes' => 'data-not-equal="-1"', 'additionalAttributes' => 'data-not-equal="-1"',
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
)) ))
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
@ -81,7 +82,8 @@
'decimals' => $userSettings['stock_decimal_places_prices'], 'decimals' => $userSettings['stock_decimal_places_prices'],
'hint' => $__t('Per stock quantity unit'), 'hint' => $__t('Per stock quantity unit'),
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'), '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( @include('components.shoppinglocationpicker', array(
'label' => 'Store', 'label' => 'Store',

View File

@ -88,7 +88,7 @@
'min' => 0, 'min' => 0,
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'invalidFeedback' => $__t('This cannot be lower than %s', '1'), 'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalCssClasses' => 'user-setting-control' 'additionalCssClasses' => 'user-setting-control locale-number-input locale-number-quantity-amount',
)) ))
<div class="form-group"> <div class="form-group">
@ -125,7 +125,7 @@
'min' => 0, 'min' => 0,
'decimals' => $userSettings['stock_decimal_places_amounts'], 'decimals' => $userSettings['stock_decimal_places_amounts'],
'invalidFeedback' => $__t('This cannot be lower than %s', '1'), 'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalCssClasses' => 'user-setting-control' 'additionalCssClasses' => 'user-setting-control locale-number-input locale-number-quantity-amount'
)) ))
<h4 class="mt-2">{{ $__t('Common') }}</h4> <h4 class="mt-2">{{ $__t('Common') }}</h4>