diff --git a/config-dist.php b/config-dist.php index 85793b05..549d7bbf 100644 --- a/config-dist.php +++ b/config-dist.php @@ -108,6 +108,9 @@ 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/controllers/RecipesController.php b/controllers/RecipesController.php index e065a2cc..a3ad0c98 100644 --- a/controllers/RecipesController.php +++ b/controllers/RecipesController.php @@ -30,20 +30,20 @@ class RecipesController extends BaseController if (isset($request->getQueryParams()['recipe'])) { $selectedRecipe = $this->Database->recipes($request->getQueryParams()['recipe']); - $selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $request->getQueryParams()['recipe'])->orderBy('ingredient_group'); + $selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $request->getQueryParams()['recipe'])->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC'); } else { foreach ($recipes as $recipe) { $selectedRecipe = $recipe; - $selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $recipe->id)->orderBy('ingredient_group'); + $selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $recipe->id)->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC'); break; } } $selectedRecipeSubRecipes = $this->Database->recipes()->where('id IN (SELECT includes_recipe_id FROM recipes_nestings_resolved WHERE recipe_id = :1 AND includes_recipe_id != :1)', $selectedRecipe->id)->orderBy('name')->fetchAll(); - $selectedRecipeSubRecipesPositions = $this->Database->recipes_pos_resolved()->where('recipe_id = :1', $selectedRecipe->id)->orderBy('ingredient_group')->fetchAll(); + $selectedRecipeSubRecipesPositions = $this->Database->recipes_pos_resolved()->where('recipe_id = :1', $selectedRecipe->id)->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC')->fetchAll(); $includedRecipeIdsAbsolute = array(); $includedRecipeIdsAbsolute[] = $selectedRecipe->id; @@ -125,6 +125,11 @@ class RecipesController extends BaseController } } + public function RecipesSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + { + return $this->AppContainer->view->render($response, 'recipessettings'); + } + public function MealPlan(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { $recipes = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(); diff --git a/public/viewjs/recipessettings.js b/public/viewjs/recipessettings.js new file mode 100644 index 00000000..0f169949 --- /dev/null +++ b/public/viewjs/recipessettings.js @@ -0,0 +1,4 @@ +if (BoolVal(Grocy.UserSettings.recipe_ingredient_display_product_group)) +{ + $("#recipe_ingredient_display_product_group").prop("checked", true); +} diff --git a/routes.php b/routes.php index df35f7e5..95990ba9 100644 --- a/routes.php +++ b/routes.php @@ -70,6 +70,7 @@ $app->group('', function() $this->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm'); $this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm'); $this->get('/mealplan', '\Grocy\Controllers\RecipesController:MealPlan'); + $this->get('/recipessettings', '\Grocy\Controllers\RecipesController:RecipesSettings'); } // Chore routes diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 985902f8..fd03d075 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -404,6 +404,9 @@ @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 95871ab2..af84fb17 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -195,12 +195,16 @@ @if(count($selectedRecipeSubRecipePositionsFiltered) > 0)