mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Fixed zero decimals handling (fixes #1213)
This commit is contained in:
@@ -267,7 +267,7 @@
|
||||
'id' => 'product_amount',
|
||||
'label' => 'Amount',
|
||||
'contextInfoId' => 'amount_qu_unit',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'isRequired' => false,
|
||||
'value' => $value,
|
||||
|
@@ -50,7 +50,7 @@
|
||||
@if(!empty($max))
|
||||
max="{{ number_format($max, $decimals, '.', '') }}"
|
||||
@endif
|
||||
step="@if($decimals == 0){{1}}@else{{'.' . str_repeat('0', $decimals - 1) . '1'}}@endif"
|
||||
step="@if($decimals <= 0){{1}}@else{{'.' . str_repeat('0', $decimals - 1) . '1'}}@endif"
|
||||
data-decimals="{{ $decimals }}"
|
||||
@if($isRequired)
|
||||
required
|
||||
|
@@ -18,7 +18,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'display_amount',
|
||||
'label' => $label,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'additionalGroupCssClasses' => 'col-sm-5 col-xs-12 my-0',
|
||||
|
@@ -12,6 +12,7 @@
|
||||
<script>
|
||||
Grocy.QuantityUnits = {!! json_encode($quantityUnits) !!};
|
||||
Grocy.QuantityUnitConversionsResolved = {!! json_encode($quantityUnitConversionsResolved) !!};
|
||||
Grocy.DefaultMinAmount = '{{$DEFAULT_MIN_AMOUNT}}';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
|
@@ -8,6 +8,7 @@
|
||||
<script>
|
||||
Grocy.QuantityUnits = {!! json_encode($quantityUnits) !!};
|
||||
Grocy.QuantityUnitConversionsResolved = {!! json_encode($quantityUnitConversionsResolved) !!};
|
||||
Grocy.DefaultMinAmount = '{{$DEFAULT_MIN_AMOUNT}}';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
@@ -81,7 +82,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'price',
|
||||
'label' => 'Price',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices']),
|
||||
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||
'value' => '',
|
||||
'hint' => $__t('Per stock quantity unit', GROCY_CURRENCY),
|
||||
|
@@ -62,7 +62,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'recipe_servings',
|
||||
'label' => 'Servings',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => '1',
|
||||
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
|
||||
|
@@ -287,7 +287,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'qu_factor_purchase_to_stock',
|
||||
'label' => 'Factor purchase to stock quantity unit',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'additionalCssClasses' => 'input-group-qu locale-number-input locale-number-quantity-amount',
|
||||
@@ -314,7 +314,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'tare_weight',
|
||||
'label' => 'Tare weight',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'additionalAttributes' => $additionalAttributes,
|
||||
@@ -387,7 +387,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'quick_consume_amount',
|
||||
'label' => 'Quick consume amount',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'hint' => $__t('This amount is used for the "quick consume/open buttons" on the stock overview page (related to quantity unit stock)'),
|
||||
|
@@ -12,6 +12,7 @@
|
||||
<script>
|
||||
Grocy.QuantityUnits = {!! json_encode($quantityUnits) !!};
|
||||
Grocy.QuantityUnitConversionsResolved = {!! json_encode($quantityUnitConversionsResolved) !!};
|
||||
Grocy.DefaultMinAmount = '{{$DEFAULT_MIN_AMOUNT}}';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
@@ -101,7 +102,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'price',
|
||||
'label' => 'Price',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices'] - 1) . '1',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices']),
|
||||
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||
'value' => '',
|
||||
'contextInfoId' => 'price-hint',
|
||||
|
@@ -85,7 +85,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'factor',
|
||||
'label' => 'Factor',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'additionalHtmlElements' => '<p id="qu-conversion-info"
|
||||
|
@@ -40,7 +40,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => 0,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'isRequired' => false,
|
||||
'value' => 1,
|
||||
|
@@ -55,7 +55,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'base_servings',
|
||||
'label' => 'Servings',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'hint' => $__t('The ingredients listed here result in this amount of servings'),
|
||||
@@ -351,7 +351,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'includes_servings',
|
||||
'label' => 'Servings',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => '1',
|
||||
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
|
||||
|
@@ -9,6 +9,10 @@
|
||||
@section('viewJsName', 'recipeposform')
|
||||
|
||||
@section('content')
|
||||
<script>
|
||||
Grocy.DefaultMinAmount = '{{$DEFAULT_MIN_AMOUNT}}';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="title-related-links">
|
||||
@@ -111,7 +115,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'price_factor',
|
||||
'label' => 'Price factor',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => '',
|
||||
'hint' => $__t('The resulting price of this ingredient will be multiplied by this factor'),
|
||||
|
@@ -330,7 +330,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'servings-scale',
|
||||
'label' => 'Desired servings',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $recipe->desired_servings,
|
||||
'additionalAttributes' => 'data-recipe-id="' . $recipe->id . '"',
|
||||
|
@@ -72,7 +72,7 @@
|
||||
@include('components.productamountpicker', array(
|
||||
'value' => $value,
|
||||
'initialQuId' => $initialQuId,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'isRequired' => false
|
||||
))
|
||||
|
||||
|
@@ -56,7 +56,7 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'amount',
|
||||
'value' => $stockEntry->amount,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'min' => $DEFAULT_MIN_AMOUNT,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'label' => 'Amount',
|
||||
'contextInfoId' => 'amount_qu_unit',
|
||||
@@ -78,7 +78,7 @@
|
||||
'id' => 'price',
|
||||
'value' => $price,
|
||||
'label' => 'Price',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices'] - 1) . '1',
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices']),
|
||||
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||
'hint' => $__t('Per stock quantity unit'),
|
||||
'isRequired' => false,
|
||||
|
Reference in New Issue
Block a user