From aa787e765e0b0eb58b08e9551930f934c578b94c Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 10 Feb 2020 18:24:15 +0100 Subject: [PATCH] Changelog, small changes and added missing localization strings for #556 --- changelog/56_UNRELEASED_2020-xx-xx.md | 1 + config-dist.php | 6 +++--- localization/strings.pot | 9 +++++++++ migrations/0098.sql | 6 ++++++ public/viewjs/recipessettings.js | 4 ++-- views/layout/default.blade.php | 6 +++--- views/recipes.blade.php | 4 ++-- views/recipessettings.blade.php | 6 +++--- 8 files changed, 29 insertions(+), 13 deletions(-) diff --git a/changelog/56_UNRELEASED_2020-xx-xx.md b/changelog/56_UNRELEASED_2020-xx-xx.md index 93bf010e..0c5f4633 100644 --- a/changelog/56_UNRELEASED_2020-xx-xx.md +++ b/changelog/56_UNRELEASED_2020-xx-xx.md @@ -12,6 +12,7 @@ - Variable ingredient amounts are now marked accordingly on the renedered recipe - After selecting a recipe on mobile devices, the page now automatically scrolls to the recipe card - Added the recipes base servings to be displayed on the recipe card and properly named the servings column in the recipes list/table (thanks @kriddles) +- Added that recipe ingredients can now also be displayed grouped by the products product group (additionally to the ingredient group, new option in the recipes settings / top right corner settings menu) (defaults to `false`, so no changed behavior when not configured) (thanks @kriddles) - Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty - Fixed that when reloading the "new recipe"-page (or when it gets auto-reloaded due to "Auto reload on external changes" is enabled), for each reload a new recipe was created - Fixed that the recipe "fullscreen card" was not correctly displayed diff --git a/config-dist.php b/config-dist.php index 549d7bbf..76e50a5c 100644 --- a/config-dist.php +++ b/config-dist.php @@ -99,6 +99,9 @@ DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', DefaultUserSetting('shopping_list_show_calendar', false); DefaultUserSetting('shopping_list_disable_auto_compact_view_on_mobile', false); +# Recipe settings +DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group + # Chores settings DefaultUserSetting('chores_due_soon_days', 5); @@ -108,9 +111,6 @@ DefaultUserSetting('batteries_due_soon_days', 5); # Tasks settings DefaultUserSetting('tasks_due_soon_days', 5); -# Recipe settings -DefaultUserSetting('recipe_ingredient_display_product_group', false); // Display the product group information in the ingredient list - # If the page should be automatically reloaded when there was # an external change DefaultUserSetting('auto_reload_on_db_change', true); diff --git a/localization/strings.pot b/localization/strings.pot index d227d5ac..07a6e805 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1735,3 +1735,12 @@ msgstr "" msgid "Base: %s" msgstr "" + +msgid "Recipes settings" +msgstr "" + +msgid "Recipe card" +msgstr "" + +msgid "Group ingredients by their product group" +msgstr "" diff --git a/migrations/0098.sql b/migrations/0098.sql index f554e5fd..abbe6b71 100644 --- a/migrations/0098.sql +++ b/migrations/0098.sql @@ -18,6 +18,7 @@ SELECT (CASE WHEN rp.only_check_single_unit_in_stock = 1 THEN 1 ELSE rp.amount * (r.desired_servings*1.0 / r.base_servings*1.0) * (rnr.includes_servings*1.0 / CASE WHEN rnr.recipe_id != rnr.includes_recipe_id THEN rnrr.base_servings*1.0 ELSE 1 END) END / p.qu_factor_purchase_to_stock) * pcp.last_price * rp.price_factor AS costs, CASE WHEN rnr.recipe_id = rnr.includes_recipe_id THEN 0 ELSE 1 END AS is_nested_recipe_pos, rp.ingredient_group, + pg.name as product_group, rp.id, -- Just a dummy id column r.type as recipe_type, rnr.includes_recipe_id as child_recipe_id, @@ -34,6 +35,8 @@ JOIN recipes_pos rp ON rnr.includes_recipe_id = rp.recipe_id JOIN products p ON rp.product_id = p.id +LEFT JOIN product_groups pg + ON p.product_group_id = pg.id LEFT JOIN ( SELECT product_id, SUM(amount) AS amount FROM shopping_list @@ -63,6 +66,7 @@ SELECT (CASE WHEN rp.only_check_single_unit_in_stock = 1 THEN 1 ELSE rp.amount * (r.desired_servings*1.0 / r.base_servings*1.0) * (rnr.includes_servings*1.0 / CASE WHEN rnr.recipe_id != rnr.includes_recipe_id THEN rnrr.base_servings*1.0 ELSE 1 END) END / p.qu_factor_purchase_to_stock) * pcp.last_price * rp.price_factor AS costs, CASE WHEN rnr.recipe_id = rnr.includes_recipe_id THEN 0 ELSE 1 END AS is_nested_recipe_pos, rp.ingredient_group, + pg.name as product_group, rp.id, -- Just a dummy id column r.type as recipe_type, rnr.includes_recipe_id as child_recipe_id, @@ -79,6 +83,8 @@ JOIN recipes_pos rp ON rnr.includes_recipe_id = rp.recipe_id JOIN products p ON rp.product_id = p.id +LEFT JOIN product_groups pg + ON p.product_group_id = pg.id LEFT JOIN ( SELECT product_id, SUM(amount) AS amount FROM shopping_list diff --git a/public/viewjs/recipessettings.js b/public/viewjs/recipessettings.js index 0f169949..e59593bd 100644 --- a/public/viewjs/recipessettings.js +++ b/public/viewjs/recipessettings.js @@ -1,4 +1,4 @@ -if (BoolVal(Grocy.UserSettings.recipe_ingredient_display_product_group)) +if (BoolVal(Grocy.UserSettings.recipe_ingredients_group_by_product_group)) { - $("#recipe_ingredient_display_product_group").prop("checked", true); + $("#recipe_ingredients_group_by_product_group").prop("checked", true); } diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index fd03d075..d07a4500 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -395,6 +395,9 @@ @if(GROCY_FEATURE_FLAG_SHOPPINGLIST)  {{ $__t('Shopping list settings') }} @endif + @if(GROCY_FEATURE_FLAG_RECIPES) +  {{ $__t('Recipes settings') }} + @endif @if(GROCY_FEATURE_FLAG_CHORES)  {{ $__t('Chores settings') }} @endif @@ -404,9 +407,6 @@ @if(GROCY_FEATURE_FLAG_TASKS)  {{ $__t('Tasks settings') }} @endif - @if(GROCY_FEATURE_FLAG_RECIPES) -  {{ $__t('Recipes settings') }} - @endif  {{ $__t('Manage users') }} diff --git a/views/recipes.blade.php b/views/recipes.blade.php index af84fb17..70c14965 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -201,7 +201,7 @@ @if($lastIngredientGroup != $selectedRecipePosition->ingredient_group)
{{ $selectedRecipePosition->ingredient_group }}
@endif - @if(boolval($userSettings['recipe_ingredient_display_product_group']) && $lastProductGroup != $selectedRecipePosition->product_group) + @if(boolval($userSettings['recipe_ingredients_group_by_product_group']) && $lastProductGroup != $selectedRecipePosition->product_group)
{{ $selectedRecipePosition->product_group }}
@endif
  • @@ -258,7 +258,7 @@ @if($lastIngredientGroup != $selectedRecipePosition->ingredient_group)
    {{ $selectedRecipePosition->ingredient_group }}
    @endif - @if(boolval($userSettings['recipe_ingredient_display_product_group']) && $lastProductGroup != $selectedRecipePosition->product_group) + @if(boolval($userSettings['recipe_ingredients_group_by_product_group']) && $lastProductGroup != $selectedRecipePosition->product_group)
    {{ $selectedRecipePosition->product_group }}
    @endif
  • diff --git a/views/recipessettings.blade.php b/views/recipessettings.blade.php index 562be43a..eedc135d 100644 --- a/views/recipessettings.blade.php +++ b/views/recipessettings.blade.php @@ -9,11 +9,11 @@

    @yield('title')

    -

    {{ $__t('Recipe card ingredients') }}

    +

    {{ $__t('Recipe card') }}

    -