From 10bd5ce9007b60352b69602c897f12e41bf1147b Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 13 Nov 2021 17:05:23 +0100 Subject: [PATCH] Added a new "Presets for new products" stock setting for the "Default due days" option of new products (closes #1552) --- changelog/65_UNRELEASED_xxxx-xx-xx.md | 1 + config-dist.php | 1 + public/viewjs/productform.js | 5 +++++ public/viewjs/stocksettings.js | 1 + views/stocksettings.blade.php | 8 ++++++++ 5 files changed, 16 insertions(+) diff --git a/changelog/65_UNRELEASED_xxxx-xx-xx.md b/changelog/65_UNRELEASED_xxxx-xx-xx.md index 122cec69..7923db07 100644 --- a/changelog/65_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/65_UNRELEASED_xxxx-xx-xx.md @@ -1,6 +1,7 @@ - The "Below min. stock amount" filter on the stock overview page now also includes due-soon, overdue or already expired products - The default shopping list (named "Shopping list"; localized) can now be renamed - Added the products average price as a (hidden by default) column on the stock overview page +- Added a new "Presets for new products" stock setting for the "Default due days" option of new products - Fixed that the "Stay logged in permanently" checkbox on the login page had no effect (thanks @0) - Fixed that the labels of context-/more-menu items were not readable in Night Mode (thanks @corbolais) - Fixed that auto night mode over midnight did not always work diff --git a/config-dist.php b/config-dist.php index dc654736..68a6051a 100644 --- a/config-dist.php +++ b/config-dist.php @@ -146,6 +146,7 @@ DefaultUserSetting('keep_screen_on_when_fullscreen_card', false); // Keep the sc DefaultUserSetting('product_presets_location_id', -1); // Default location id for new products (-1 means no location is preset) DefaultUserSetting('product_presets_product_group_id', -1); // Default product group id for new products (-1 means no product group is preset) DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for new products (-1 means no quantity unit is preset) +DefaultUserSetting('product_presets_default_due_days', 0); // Default due days for new products (-1 means that the product will be never overdue) DefaultUserSetting('stock_decimal_places_amounts', 4); // Default decimal places allowed for amounts DefaultUserSetting('stock_decimal_places_prices', 2); // Default decimal places allowed for prices DefaultUserSetting('stock_auto_decimal_separator_prices', false); diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 96ffb660..63a83c17 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -504,6 +504,11 @@ else if (Grocy.EditMode === 'create') { $("select.input-group-qu").val(Grocy.UserSettings.product_presets_qu_id); } + + if (Grocy.UserSettings.product_presets_default_due_days.toString() !== '0') + { + $("#default_best_before_days").val(Grocy.UserSettings.product_presets_default_due_days); + } } Grocy.Components.ProductPicker.GetPicker().on('change', function(e) diff --git a/public/viewjs/stocksettings.js b/public/viewjs/stocksettings.js index d0e39682..204be0b0 100644 --- a/public/viewjs/stocksettings.js +++ b/public/viewjs/stocksettings.js @@ -1,6 +1,7 @@ $("#product_presets_location_id").val(Grocy.UserSettings.product_presets_location_id); $("#product_presets_product_group_id").val(Grocy.UserSettings.product_presets_product_group_id); $("#product_presets_qu_id").val(Grocy.UserSettings.product_presets_qu_id); +$("#product_presets_default_due_days").val(Grocy.UserSettings.product_presets_default_due_days); $("#stock_due_soon_days").val(Grocy.UserSettings.stock_due_soon_days); $("#stock_default_purchase_amount").val(Grocy.UserSettings.stock_default_purchase_amount); $("#stock_default_consume_amount").val(Grocy.UserSettings.stock_default_consume_amount); diff --git a/views/stocksettings.blade.php b/views/stocksettings.blade.php index 19799311..76dca026 100644 --- a/views/stocksettings.blade.php +++ b/views/stocksettings.blade.php @@ -55,6 +55,14 @@ @endforeach + + @include('components.numberpicker', array( + 'id' => 'product_presets_default_due_days', + 'additionalAttributes' => 'data-setting-key="product_presets_default_due_days"', + 'label' => 'Default due days', + 'min' => -1, + 'additionalCssClasses' => 'user-setting-control' + ))

{{ $__t('Stock overview') }}