diff --git a/js/viewjs/mealplan.js b/js/viewjs/mealplan.js
index 3858c71a..35c036b4 100644
--- a/js/viewjs/mealplan.js
+++ b/js/viewjs/mealplan.js
@@ -1,4 +1,6 @@
-import { Calendar } from '@fullcalendar/core';
+/* global fullcalendarEventSources, internalRecipes, recipesResolved */
+
+import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
import bootstrapPlugin from '@fullcalendar/bootstrap';
import momentPlugin from '@fullcalendar/moment/main';
@@ -107,6 +109,30 @@ var calendar = new Calendar(document.getElementById("calendar"), {
element.attr("data-meal-plan-entry", event.mealPlanEntry);
var mealPlanEntry = JSON.parse(event.mealPlanEntry);
+ var costsAndCaloriesPerDay = "";
+
+ if (event.type != "note")
+ {
+ var dayRecipeName = toMoment(info.event.start, calendar).format("YYYY-MM-DD");
+ var dayRecipe = internalRecipes.find(elem => elem.name == dayRecipeName);
+ var dayRecipeResolved = recipesResolved.find(elem => elem.recipe_id == dayRecipe.id);
+
+ if (!$("#day-summary-" + dayRecipeName).length) // This runs for every event/recipe, so maybe multiple times per day, so only add the day summary once
+ {
+ if (dayRecipe != null)
+ {
+ if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
+ {
+ costsAndCaloriesPerDay = '
' + dayRecipeResolved.costs + ' / ' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '';
+ }
+ else
+ {
+ costsAndCaloriesPerDay = '' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '';
+ }
+ $(".fc-day-header[data-date='" + dayRecipeName + "']").append('' + costsAndCaloriesPerDay + '
');
+ }
+ }
+ }
if (event.type == "recipe")
{
@@ -137,9 +163,10 @@ var calendar = new Calendar(document.getElementById("calendar"), {
if (resolvedRecipe.need_fulfilled != 1)
{
fulfillmentInfoHtml = __t('Not enough in stock');
- var fulfillmentIconHtml = '';
+ fulfillmentIconHtml = '';
}
- var costsAndCaloriesPerServing = ""
+
+ var costsAndCaloriesPerServing = "";
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
costsAndCaloriesPerServing = '' + resolvedRecipe.costs + ' / ' + resolvedRecipe.calories + ' kcal ' + __t('per serving') + '';
@@ -174,27 +201,6 @@ var calendar = new Calendar(document.getElementById("calendar"), {
{
element.html(element.html() + '![]()
')
}
-
- var dayRecipeName = toMoment(info.event.start, calendar).format("YYYY-MM-DD");
- if (!$("#day-summary-" + dayRecipeName).length) // This runs for every event/recipe, so maybe multiple times per day, so only add the day summary once
- {
- var dayRecipe = internalRecipes.find(elem => elem.name == dayRecipeName);
- if (dayRecipe != null)
- {
- var dayRecipeResolved = recipesResolved.find(elem => elem.recipe_id == dayRecipe.id);
-
- var costsAndCaloriesPerDay = ""
- if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
- {
- costsAndCaloriesPerDay = '' + dayRecipeResolved.costs + ' / ' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '';
- }
- else
- {
- costsAndCaloriesPerDay = '' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '';
- }
- $(".fc-day-header[data-date='" + dayRecipeName + "']").append('' + costsAndCaloriesPerDay + '
');
- }
- }
}
if (event.type == "product")
{
@@ -224,14 +230,13 @@ var calendar = new Calendar(document.getElementById("calendar"), {
}
fulfillmentInfoHtml = __t('Not enough in stock');
- var fulfillmentIconHtml = '';
+ fulfillmentIconHtml = '';
if (parseFloat(productDetails.stock_amount_aggregated) >= parseFloat(mealPlanEntry.product_amount))
{
- var fulfillmentInfoHtml = __t('Enough in stock');
- var fulfillmentIconHtml = '';
+ fulfillmentInfoHtml = __t('Enough in stock');
+ fulfillmentIconHtml = '';
}
- var costsAndCaloriesPerServing = ""
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
costsAndCaloriesPerServing = '' + productDetails.last_price * mealPlanEntry.product_amount + ' / ' + productDetails.product.calories * mealPlanEntry.product_amount + ' kcal ' + '';
@@ -259,27 +264,6 @@ var calendar = new Calendar(document.getElementById("calendar"), {
{
element.html(element.html() + '![]()
')
}
-
- var dayRecipeName = toMoment(info.event.start, calendar).format("YYYY-MM-DD");
- if (!$("#day-summary-" + dayRecipeName).length) // This runs for every event/recipe, so maybe multiple times per day, so only add the day summary once
- {
- var dayRecipe = internalRecipes.find(elem => elem.name == dayRecipeName);
- if (dayRecipe != null)
- {
- var dayRecipeResolved = recipesResolved.find(elem => elem.recipe_id == dayRecipe.id);
-
- var costsAndCaloriesPerDay = ""
- if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
- {
- costsAndCaloriesPerDay = '' + dayRecipeResolved.costs + ' / ' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '';
- }
- else
- {
- costsAndCaloriesPerDay = '' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '';
- }
- $(".fc-day-header[data-date='" + dayRecipeName + "']").append('' + costsAndCaloriesPerDay + '
');
- }
- }
}
else if (event.type == "note")
{
@@ -597,9 +581,9 @@ $('#add-product-form input').keydown(function(event)
}
});
-$(document).on("keydown", "#servings", function(e)
+$(document).on("keydown", "#servings", function(event)
{
- if (event.keyCode === 13) //Enter
+ if (event.key === 13) //Enter
{
event.preventDefault();
@@ -854,20 +838,6 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
}
});
-function UndoStockTransaction(transactionId)
-{
- Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', {},
- function(result)
- {
- toastr.success(__t("Transaction successfully undone"));
- },
- function(xhr)
- {
- console.error(xhr);
- }
- );
-};
-
Grocy.Components.RecipePicker.GetPicker().on('change', function(e)
{
var recipeId = $(e.target).val();