mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Fixed meal plan did not load when a containing recipe was deleted (closes #361)
This commit is contained in:
parent
ab44566890
commit
327c1f4fb3
@ -47,6 +47,7 @@
|
|||||||
- New option "price factor" per recipe ingredient (defaults to `1`) - the resulting costs of the recipe ingredient will be multiplied by that factor
|
- New option "price factor" per recipe ingredient (defaults to `1`) - the resulting costs of the recipe ingredient will be multiplied by that factor
|
||||||
- Use this for example for spices in combination with "Only check if a single unit is in stock" to not take the full price of a pack of pepper into account for a recipe
|
- Use this for example for spices in combination with "Only check if a single unit is in stock" to not take the full price of a pack of pepper into account for a recipe
|
||||||
- The search field on the recipe overview page now also searches for product names of recipe ingredients (means it's possible to search an recipe by a product name)
|
- The search field on the recipe overview page now also searches for product names of recipe ingredients (means it's possible to search an recipe by a product name)
|
||||||
|
- Fixed a problem where the meal plan did not load when a recipe, which was already added to a the meal plan, was deleted
|
||||||
|
|
||||||
### Chores improvements
|
### Chores improvements
|
||||||
- Chores can now be assigned to users
|
- Chores can now be assigned to users
|
||||||
|
@ -135,12 +135,19 @@ class RecipesController extends BaseController
|
|||||||
$events = array();
|
$events = array();
|
||||||
foreach($this->Database->meal_plan() as $mealPlanEntry)
|
foreach($this->Database->meal_plan() as $mealPlanEntry)
|
||||||
{
|
{
|
||||||
|
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
|
||||||
|
$title = '';
|
||||||
|
if ($recipe !== null)
|
||||||
|
{
|
||||||
|
$title = $recipe->name;
|
||||||
|
}
|
||||||
|
|
||||||
$events[] = array(
|
$events[] = array(
|
||||||
'id' => $mealPlanEntry['id'],
|
'id' => $mealPlanEntry['id'],
|
||||||
'title' => FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id'])->name,
|
'title' => $title,
|
||||||
'start' => $mealPlanEntry['day'],
|
'start' => $mealPlanEntry['day'],
|
||||||
'date_format' => 'date',
|
'date_format' => 'date',
|
||||||
'recipe' => json_encode(FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id'])),
|
'recipe' => json_encode($recipe),
|
||||||
'mealPlanEntry' => json_encode($mealPlanEntry)
|
'mealPlanEntry' => json_encode($mealPlanEntry)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
9
migrations/0089.sql
Normal file
9
migrations/0089.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
CREATE TRIGGER remove_recipe_from_meal_plans AFTER DELETE ON recipes
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM meal_plan
|
||||||
|
WHERE recipe_id = OLD.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- Delete all recipes from the meal plan which doesn't exist anymore
|
||||||
|
DELETE FROM meal_plan
|
||||||
|
WHERE recipe_id NOT IN (SELECT id FROM recipes);
|
@ -59,6 +59,11 @@ var calendar = $("#calendar").fullCalendar({
|
|||||||
"eventRender": function(event, element)
|
"eventRender": function(event, element)
|
||||||
{
|
{
|
||||||
var recipe = JSON.parse(event.recipe);
|
var recipe = JSON.parse(event.recipe);
|
||||||
|
if (recipe === null || recipe === undefined)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var mealPlanEntry = JSON.parse(event.mealPlanEntry);
|
var mealPlanEntry = JSON.parse(event.mealPlanEntry);
|
||||||
var resolvedRecipe = FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", recipe.id);
|
var resolvedRecipe = FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", recipe.id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user