From 8de5700310fd532d5610ea88a27778cc80ddc2fe Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 2 Apr 2025 20:50:40 +0200 Subject: [PATCH] Allow 0 for shopping list item amounts (references #2712) --- changelog/81_UNRELEASED_xxxx-xx-xx.md | 57 +++++++++++++++++++ .../components/productamountpicker.blade.php | 11 +++- views/shoppinglistitemform.blade.php | 2 +- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 changelog/81_UNRELEASED_xxxx-xx-xx.md diff --git a/changelog/81_UNRELEASED_xxxx-xx-xx.md b/changelog/81_UNRELEASED_xxxx-xx-xx.md new file mode 100644 index 00000000..73577318 --- /dev/null +++ b/changelog/81_UNRELEASED_xxxx-xx-xx.md @@ -0,0 +1,57 @@ +> ⚠️ xxxBREAKING CHANGESxxx + +> ❗ xxxImportant upgrade informationXXX + +> 💡 xxxMinor upgrade informationXXX + +### New Feature: xxxx + +- xxx + +### Stock + +- xxx + +### Shopping list + +- An amount of `0` is now allowed for shopping list items (just a convenience optimization, it was already possible to leave the amount field empty which implicitly resulted in an amount of `0`) + +### Recipes + +- xxx + +### Meal plan + +- xxx + +### Chores + +- xxx + +### Calendar + +- xxx + +### Tasks + +- xxx + +### Batteries + +- xxx + +### Equipment + +- xxx + +### Userfields + +- xxx + +### General + +- xxx + +### API + +- xxx diff --git a/views/components/productamountpicker.blade.php b/views/components/productamountpicker.blade.php index 74769ee0..c778df12 100644 --- a/views/components/productamountpicker.blade.php +++ b/views/components/productamountpicker.blade.php @@ -10,6 +10,15 @@ @php if(empty($label)) { $label = 'Amount'; } @endphp @php if(empty($initialQuId)) { $initialQuId = '-1'; } @endphp @php if(!isset($isRequired)) { $isRequired = true; } @endphp +@php if(!isset($allowZero)) { $allowZero = false; } @endphp + +@php +$minLocal = $DEFAULT_MIN_AMOUNT; +if ($allowZero) +{ +$minLocal = 0; +} +@endphp
@@ -20,7 +29,7 @@ @include('components.numberpicker', array( 'id' => 'display_amount', 'label' => $label, - 'min' => $DEFAULT_MIN_AMOUNT, + 'min' => $minLocal, 'decimals' => $userSettings['stock_decimal_places_amounts'], 'value' => $value, 'additionalGroupCssClasses' => 'col-sm-5 col-12 my-0', diff --git a/views/shoppinglistitemform.blade.php b/views/shoppinglistitemform.blade.php index 1ac51c0c..9b3f9abf 100644 --- a/views/shoppinglistitemform.blade.php +++ b/views/shoppinglistitemform.blade.php @@ -72,7 +72,7 @@ @include('components.productamountpicker', array( 'value' => $value, 'initialQuId' => $initialQuId, - 'min' => $DEFAULT_MIN_AMOUNT, + 'allowZero' => true, 'isRequired' => false ))