mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 11:06:36 +00:00
450 updates (#518)
* prevent seeing undefinde if no recipes * disable weekRecipeConsume if weekCosts are zero * reword title * Add meal plan notes and products to Calendar
This commit is contained in:
@@ -49,9 +49,9 @@ var calendar = $("#calendar").fullCalendar({
|
|||||||
var weekCosts = 0;
|
var weekCosts = 0;
|
||||||
var weekRecipeOrderMissingButtonHtml = "";
|
var weekRecipeOrderMissingButtonHtml = "";
|
||||||
var weekRecipeConsumeButtonHtml = "";
|
var weekRecipeConsumeButtonHtml = "";
|
||||||
|
var weekCostsHtml = "";
|
||||||
if (weekRecipe !== null)
|
if (weekRecipe !== null)
|
||||||
{
|
{
|
||||||
var weekCostsHtml = "";
|
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
{
|
{
|
||||||
weekCosts = FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", weekRecipe.id).costs;
|
weekCosts = FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", weekRecipe.id).costs;
|
||||||
@@ -64,12 +64,13 @@ var calendar = $("#calendar").fullCalendar({
|
|||||||
weekRecipeOrderMissingButtonDisabledClasses = "disabled";
|
weekRecipeOrderMissingButtonDisabledClasses = "disabled";
|
||||||
}
|
}
|
||||||
var weekRecipeConsumeButtonDisabledClasses = "";
|
var weekRecipeConsumeButtonDisabledClasses = "";
|
||||||
if (FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", weekRecipe.id).need_fulfilled == 0)
|
console.log(weekCosts);
|
||||||
|
if (FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", weekRecipe.id).need_fulfilled == 0 || weekCosts == 0)
|
||||||
{
|
{
|
||||||
weekRecipeConsumeButtonDisabledClasses = "disabled";
|
weekRecipeConsumeButtonDisabledClasses = "disabled";
|
||||||
}
|
}
|
||||||
weekRecipeOrderMissingButtonHtml = '<a class="ml-1 btn btn-outline-primary btn-xs recipe-order-missing-button ' + weekRecipeOrderMissingButtonDisabledClasses + '" href="#" data-toggle="tooltip" title="' + __t("Put missing products on shopping list") + '" data-recipe-id="' + weekRecipe.id.toString() + '" data-recipe-name="' + weekRecipe.name + '" data-recipe-type="' + weekRecipe.type + '"><i class="fas fa-cart-plus"></i></a>'
|
weekRecipeOrderMissingButtonHtml = '<a class="ml-1 btn btn-outline-primary btn-xs recipe-order-missing-button ' + weekRecipeOrderMissingButtonDisabledClasses + '" href="#" data-toggle="tooltip" title="' + __t("Put missing products on shopping list") + '" data-recipe-id="' + weekRecipe.id.toString() + '" data-recipe-name="' + weekRecipe.name + '" data-recipe-type="' + weekRecipe.type + '"><i class="fas fa-cart-plus"></i></a>'
|
||||||
weekRecipeConsumeButtonHtml = '<a class="ml-1 btn btn-outline-success btn-xs recipe-consume-button ' + weekRecipeConsumeButtonDisabledClasses + '" href="#" data-toggle="tooltip" title="' + __t("Consume all ingredients needed by this recipe") + '" data-recipe-id="' + weekRecipe.id.toString() + '" data-recipe-name="' + weekRecipe.name + '" data-recipe-type="' + weekRecipe.type + '"><i class="fas fa-utensils"></i></a>'
|
weekRecipeConsumeButtonHtml = '<a class="ml-1 btn btn-outline-success btn-xs recipe-consume-button ' + weekRecipeConsumeButtonDisabledClasses + '" href="#" data-toggle="tooltip" title="' + __t("Consume all ingredients needed by these recipes or products") + '" data-recipe-id="' + weekRecipe.id.toString() + '" data-recipe-name="' + weekRecipe.name + '" data-recipe-type="' + weekRecipe.type + '"><i class="fas fa-utensils"></i></a>'
|
||||||
}
|
}
|
||||||
$(".fc-header-toolbar .fc-center").html("<h4>" + weekCostsHtml + weekRecipeOrderMissingButtonHtml + weekRecipeConsumeButtonHtml + "</h4>");
|
$(".fc-header-toolbar .fc-center").html("<h4>" + weekCostsHtml + weekRecipeOrderMissingButtonHtml + weekRecipeConsumeButtonHtml + "</h4>");
|
||||||
},
|
},
|
||||||
|
@@ -92,7 +92,7 @@ class CalendarService extends BaseService
|
|||||||
|
|
||||||
$recipes = $this->Database->recipes();
|
$recipes = $this->Database->recipes();
|
||||||
$mealPlanDayRecipes = $this->Database->recipes()->where('type', 'mealplan-day');
|
$mealPlanDayRecipes = $this->Database->recipes()->where('type', 'mealplan-day');
|
||||||
$titlePrefix = $this->LocalizationService->__t('Meal plan') . ': ';
|
$titlePrefix = $this->LocalizationService->__t('Meal plan recipe') . ': ';
|
||||||
$mealPlanRecipeEvents = array();
|
$mealPlanRecipeEvents = array();
|
||||||
foreach($mealPlanDayRecipes as $mealPlanDayRecipe)
|
foreach($mealPlanDayRecipes as $mealPlanDayRecipe)
|
||||||
{
|
{
|
||||||
@@ -108,6 +108,31 @@ class CalendarService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents, $mealPlanRecipeEvents);
|
$mealPlanDayNotes = $this->Database->meal_plan()->where('type', 'note');
|
||||||
|
$titlePrefix = $this->LocalizationService->__t('Meal plan note') . ': ';
|
||||||
|
$mealPlanNotesEvents = array();
|
||||||
|
foreach($mealPlanDayNotes as $mealPlanDayNote)
|
||||||
|
{
|
||||||
|
$mealPlanNotesEvents[] = array(
|
||||||
|
'title' => $titlePrefix . $mealPlanDayNote->note,
|
||||||
|
'start' => $mealPlanDayNote->day,
|
||||||
|
'date_format' => 'date'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$products = $this->Database->products();
|
||||||
|
$mealPlanDayProducts = $this->Database->meal_plan()->where('type', 'product');
|
||||||
|
$titlePrefix = $this->LocalizationService->__t('Meal plan product') . ': ';
|
||||||
|
$mealPlanProductEvents = array();
|
||||||
|
foreach($mealPlanDayProducts as $mealPlanDayProduct)
|
||||||
|
{
|
||||||
|
$mealPlanProductEvents[] = array(
|
||||||
|
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($products, 'id', $mealPlanDayProduct->product_id)->name,
|
||||||
|
'start' => $mealPlanDayProduct->day,
|
||||||
|
'date_format' => 'date'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents, $mealPlanRecipeEvents, $mealPlanNotesEvents, $mealPlanProductEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user