Fixed price input decimals, started reviewing all number inputs (fixes #1076, references #998)

This commit is contained in:
Bernd Bestel 2020-10-19 20:03:26 +02:00
parent 6e1e90984f
commit 80beff2cae
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
19 changed files with 59 additions and 28 deletions

View File

@ -255,7 +255,8 @@
'id' => 'product_amount',
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 0.0001,
'min' => 0.01,
'decimals' => 2,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'isRequired' => false,
'value' => $value

View File

@ -5,6 +5,7 @@
@php if(!isset($value)) { $value = 1; } @endphp
@php if(empty($min)) { $min = 0; } @endphp
@php if(empty($max)) { $max = 999999; } @endphp
@php if(empty($decimals)) { $decimals = 0; } @endphp
@php if(empty($hint)) { $hint = ''; } @endphp
@php if(empty($hintId)) { $hintId = ''; } @endphp
@php if(empty($additionalCssClasses)) { $additionalCssClasses = ''; } @endphp
@ -33,9 +34,9 @@
name="{{ $id }}"
@endif
value="{{ $value }}"
min="{{ $min }}"
max="{{ $max }}"
step="{{ $min }}"
min="{{ number_format($min, $decimals, '.', '') }}"
max="{{ number_format($max, $decimals, '.', '') }}"
step="@if($decimals == 0){{1}}@else{{'.' . substr('0000000001', -$decimals)}}@endif"
@if($isRequired)
required
@endif>

View File

@ -11,7 +11,8 @@
@include('components.numberpicker', array(
'id' => 'display_amount',
'label' => 'Amount',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('This cannot be negative and must be an integral number'),
'additionalGroupCssClasses' => 'col-4 mb-1',

View File

@ -41,7 +41,8 @@
'id' => '',
'label' => $userfield->caption,
'noNameAttribute' => true,
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'isRequired' => false,
'additionalCssClasses' => 'userfield-input',
'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"'

View File

@ -43,15 +43,19 @@
'nextInputSelector' => '#amount',
'disallowAddProductWorkflows' => true
))
<label for="consume-exact-amount" class="d-none">
<input type="checkbox" id="consume-exact-amount" name="exact_amount">
<label for="consume-exact-amount"
class="d-none">
<input type="checkbox"
id="consume-exact-amount"
name="exact_amount">
{{ $__t('Consume exact amount') }}
</label>
@include('components.numberpicker', array(
'id' => 'amount',
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => 0,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"

View File

@ -23,6 +23,7 @@
'label' => 'New amount',
'hintId' => 'new_amount_qu_unit',
'min' => 0,
'decimals' => 2,
'value' => 1,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'additionalAttributes' => 'data-not-equal="-1"',
@ -64,6 +65,7 @@
'id' => 'price',
'label' => 'Price',
'min' => 0,
'decimals' => 2,
'value' => '',
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
'additionalHtmlContextHelp' => '<br><span class="small text-muted">' . $__t('This will apply to added products') . '</span>',

View File

@ -61,7 +61,8 @@
@include('components.numberpicker', array(
'id' => 'recipe_servings',
'label' => 'Servings',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => '1',
'invalidFeedback' => $__t('This cannot be lower than %s', '1')
))

View File

@ -55,7 +55,8 @@
@include('components.numberpicker', array(
'id' => 'qu_factor_purchase_to_stock',
'label' => 'Factor purchase to stock quantity unit',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'isRequired' => true,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),

View File

@ -142,7 +142,8 @@
@include('components.numberpicker', array(
'id' => 'min_stock_amount',
'label' => 'Minimum stock amount',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'additionalGroupCssClasses' => 'mb-1'
@ -244,7 +245,8 @@
@include('components.numberpicker', array(
'id' => 'qu_factor_purchase_to_stock',
'label' => 'Factor purchase to stock quantity unit',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalCssClasses' => 'input-group-qu',
@ -285,7 +287,8 @@
@include('components.numberpicker', array(
'id' => 'tare_weight',
'label' => 'Tare weight',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
'additionalAttributes' => $additionalAttributes,
@ -313,7 +316,8 @@
@include('components.numberpicker', array(
'id' => 'calories',
'label' => 'Energy (kcal)',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'hint' => $__t('Per stock quantity unit'),

View File

@ -47,7 +47,8 @@
'id' => 'amount',
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"
class="text-info font-italic d-none">' . $__t('Tare weight handling enabled - please weigh the whole container, the amount to be posted will be automatically calculcated') . '</div>'
@ -93,7 +94,8 @@
@include('components.numberpicker', array(
'id' => 'price',
'label' => 'Price',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => '',
'hintId' => 'price-hint',
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
@ -133,7 +135,8 @@
@include('components.numberpicker', array(
'id' => 'qu_factor_purchase_to_stock',
'label' => 'Factor purchase to stock quantity unit',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'additionalGroupCssClasses' => 'd-none',
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalCssClasses' => 'input-group-qu',

View File

@ -81,7 +81,8 @@
@include('components.numberpicker', array(
'id' => 'factor',
'label' => 'Factor',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '0', '3'),
'additionalHtmlElements' => '<p id="qu-conversion-info"

View File

@ -38,7 +38,8 @@
@include('components.numberpicker', array(
'id' => 'amount',
'label' => 'Amount',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'isRequired' => false,
'value' => 1
))

View File

@ -91,7 +91,8 @@
@include('components.numberpicker', array(
'id' => 'base_servings',
'label' => 'Servings',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'hint' => $__t('The ingredients listed here result in this amount of servings')
@ -333,7 +334,8 @@
@include('components.numberpicker', array(
'id' => 'includes_servings',
'label' => 'Servings',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => '1',
'invalidFeedback' => $__t('This cannot be lower than %s', '1')
))

View File

@ -106,7 +106,8 @@
@include('components.numberpicker', array(
'id' => 'price_factor',
'label' => 'Price factor',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'value' => '',
'hint' => $__t('The resulting price of this ingredient will be multiplied by this factor'),
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),

View File

@ -297,7 +297,8 @@
@include('components.numberpicker', array(
'id' => 'servings-scale',
'label' => 'Desired servings',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => $recipe->desired_servings,
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalAttributes' => 'data-recipe-id="' . $recipe->id . '"',

View File

@ -65,6 +65,7 @@
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 0.01,
'decimals' => 2,
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.01')
))

View File

@ -66,7 +66,8 @@
'id' => 'qu_factor_purchase_to_stock',
'label' => 'Factor purchase to stock quantity unit',
'value' => $stockEntry->qu_factor_purchase_to_stock,
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalCssClasses' => 'input-group-qu',
'additionalHtmlElements' => '<p id="qu-conversion-info"
@ -88,7 +89,8 @@
'id' => 'price',
'value' => $price,
'label' => 'Price',
'min' => 0,
'min' => 0.01,
'decimals' => 2,
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
'isRequired' => false

View File

@ -71,6 +71,7 @@
'additionalAttributes' => 'data-setting-key="stock_default_purchase_amount"',
'label' => 'Default amount for purchase',
'min' => 0,
'decimals' => 2,
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalCssClasses' => 'user-setting-control'
))
@ -80,7 +81,8 @@
'id' => 'stock_default_consume_amount',
'additionalAttributes' => 'data-setting-key="stock_default_consume_amount"',
'label' => 'Default amount for consume',
'min' => 1,
'min' => 0,
'decimals' => 2,
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalCssClasses' => 'user-setting-control'
))

View File

@ -46,7 +46,8 @@
'id' => 'amount',
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 1,
'min' => 0.01,
'decimals' => 2,
'value' => 1,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"