mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Include meal plan recipes in the calendar (closes #368)
This commit is contained in:
parent
2a9f927a13
commit
53c56cc1cb
@ -1,3 +1,4 @@
|
|||||||
- It's now possible to display a recipe directly from the meal plan (new "eye button") (thanks @kriddles)
|
- It's now possible to display a recipe directly from the meal plan (new "eye button") (thanks @kriddles)
|
||||||
- Improved the responsiveness of the meal plan and calendar page by automatically switching to a day calendar view on smaller screens (thanks for the idea @kriddles)
|
- Improved the responsiveness of the meal plan and calendar page by automatically switching to a day calendar view on smaller screens (thanks for the idea @kriddles)
|
||||||
|
- The calendar now also contains all planned recipes from the meal plan on the corresponding day
|
||||||
- Some style/CSS detail-refinements
|
- Some style/CSS detail-refinements
|
||||||
|
19
migrations/0091.sql
Normal file
19
migrations/0091.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
DROP VIEW recipes_nestings_resolved;
|
||||||
|
CREATE VIEW recipes_nestings_resolved
|
||||||
|
AS
|
||||||
|
WITH RECURSIVE r1(recipe_id, includes_recipe_id, includes_servings)
|
||||||
|
AS (
|
||||||
|
SELECT id, id, 1
|
||||||
|
FROM recipes
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT rn.recipe_id, r1.includes_recipe_id, rn.servings
|
||||||
|
FROM recipes_nestings rn, r1 r1
|
||||||
|
WHERE rn.includes_recipe_id = r1.recipe_id
|
||||||
|
LIMIT 100 -- This is just a safety limit to prevent infinite loops due to infinite nested recipes
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
*,
|
||||||
|
1 AS id -- Dummy, LessQL needs an id column
|
||||||
|
FROM r1;
|
@ -87,6 +87,23 @@ class CalendarService extends BaseService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents);
|
$recipes = $this->Database->recipes();
|
||||||
|
$mealPlanDayRecipes = $this->Database->recipes()->where('type', 'mealplan-day');
|
||||||
|
$titlePrefix = $this->LocalizationService->__t('Meal plan') . ': ';
|
||||||
|
$mealPlanRecipeEvents = array();
|
||||||
|
foreach($mealPlanDayRecipes as $mealPlanDayRecipe)
|
||||||
|
{
|
||||||
|
$recipesOfCurrentDay = $this->Database->recipes_nestings_resolved()->where('recipe_id = :1 AND includes_recipe_id != :1', $mealPlanDayRecipe->id);
|
||||||
|
foreach ($recipesOfCurrentDay as $recipeOfCurrentDay)
|
||||||
|
{
|
||||||
|
$mealPlanRecipeEvents[] = array(
|
||||||
|
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->includes_recipe_id)->name,
|
||||||
|
'start' => FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name,
|
||||||
|
'date_format' => 'date'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents, $mealPlanRecipeEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user