From 791a17fcad8264e8cebdd421993c6f439ceec271 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 31 Mar 2021 22:22:28 +0200 Subject: [PATCH] Default shopping list item amount to 1 --- changelog/62_UNRELEASED_xxxx-xx-xx.md | 3 ++- public/viewjs/shoppinglistitemform.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index e1e21364..e3a4ce1d 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -5,7 +5,8 @@ - Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape) - Fixed that the transfer page was not fully populated when opening it from the stock entries page -### Shopping list fixes +### Shopping list improvements/fixes +- The amount now defaults to `1` for adding items quicker - Fixed that shopping list prints had a grey background (thanks @Forceu) - Fixed the form validation on the shopping list item page (thanks @Forceu) diff --git a/public/viewjs/shoppinglistitemform.js b/public/viewjs/shoppinglistitemform.js index b373cbc4..5a8fdc3f 100644 --- a/public/viewjs/shoppinglistitemform.js +++ b/public/viewjs/shoppinglistitemform.js @@ -162,6 +162,12 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id); } + if ($("#display_amount").val().toString().isEmpty()) + { + $("#display_amount").val(1); + $("#display_amount").trigger("change"); + } + $('#display_amount').focus(); Grocy.FrontendHelpers.ValidateForm('shoppinglist-form'); Grocy.ShoppingListItemFormInitialLoadDone = true; @@ -244,8 +250,8 @@ if (GetUriParam("embedded") !== undefined) } var eitherRequiredFields = $("#product_id,#product_id_text_input,#note"); -eitherRequiredFields.prop('required',""); -eitherRequiredFields.on('input', function () +eitherRequiredFields.prop('required', ""); +eitherRequiredFields.on('input', function() { eitherRequiredFields.not(this).prop('required', !$(this).val().length); Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');