From 80beff2cae4f6f16916ce3758a2b66d29fd03a6e Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 19 Oct 2020 20:03:26 +0200 Subject: [PATCH] Fixed price input decimals, started reviewing all number inputs (fixes #1076, references #998) --- views/choreform.blade.php | 3 ++- views/components/numberpicker.blade.php | 7 ++++--- views/components/productamountpicker.blade.php | 3 ++- views/components/userfieldsform.blade.php | 3 ++- views/consume.blade.php | 10 +++++++--- views/inventory.blade.php | 2 ++ views/mealplan.blade.php | 3 ++- views/productbarcodesform.blade.php | 3 ++- views/productform.blade.php | 12 ++++++++---- views/purchase.blade.php | 9 ++++++--- views/quantityunitconversionform.blade.php | 3 ++- views/quantityunitpluraltesting.blade.php | 3 ++- views/recipeform.blade.php | 6 ++++-- views/recipeposform.blade.php | 3 ++- views/recipes.blade.php | 3 ++- views/shoppinglistitemform.blade.php | 1 + views/stockentryform.blade.php | 6 ++++-- views/stocksettings.blade.php | 4 +++- views/transfer.blade.php | 3 ++- 19 files changed, 59 insertions(+), 28 deletions(-) diff --git a/views/choreform.blade.php b/views/choreform.blade.php index a844a625..3ebb9651 100644 --- a/views/choreform.blade.php +++ b/views/choreform.blade.php @@ -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 diff --git a/views/components/numberpicker.blade.php b/views/components/numberpicker.blade.php index 0ad4543a..ee647cae 100644 --- a/views/components/numberpicker.blade.php +++ b/views/components/numberpicker.blade.php @@ -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> diff --git a/views/components/productamountpicker.blade.php b/views/components/productamountpicker.blade.php index 2864f644..d94cb21b 100644 --- a/views/components/productamountpicker.blade.php +++ b/views/components/productamountpicker.blade.php @@ -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', diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index 9b0dbf57..f8311384 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -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 . '"' diff --git a/views/consume.blade.php b/views/consume.blade.php index 82bb1c8b..2f40f018 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -43,15 +43,19 @@ 'nextInputSelector' => '#amount', 'disallowAddProductWorkflows' => true )) -