diff --git a/changelog/56_UNRELEASED_2020-xx-xx.md b/changelog/56_UNRELEASED_2020-xx-xx.md
index 9d3687e0..3cf2f23f 100644
--- a/changelog/56_UNRELEASED_2020-xx-xx.md
+++ b/changelog/56_UNRELEASED_2020-xx-xx.md
@@ -16,6 +16,7 @@
- Fixed that when reloading the "new recipe"-page (or when it gets auto-reloaded due to "Auto reload on external changes" is enabled), for each reload a new recipe was created
- Fixed that the recipe "fullscreen card" was not correctly displayed
- Fixed that nested recipes showed all ingredients of the nested recipes twice
+- Fixed that when displaying or consuming a recipe from the meal plan the serving amount was maybe wrong (was the one from the recipe instead the one from the meal plan entry) (thanks @kriddles)
### Meal plan improvements
- Improved that all add-dialogs can be submitted by using `ENTER` and that the next input is automatically selected after selecting a recipe/product
diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js
index d0266e7f..8960c489 100644
--- a/public/viewjs/mealplan.js
+++ b/public/viewjs/mealplan.js
@@ -582,40 +582,35 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
{
Grocy.FrontendHelpers.BeginUiBusy();
- //set the recipes desired_servings so that the views resolve correctly
- //based on the meal plan servings
- var data = { };
- data.desired_servings = servings;
-
- Grocy.Api.Put('objects/recipes/' + objectId, data,
+ // Set the recipes desired_servings so that the "recipes resolved"-views resolve correctly based on the meal plan entry servings
+ Grocy.Api.Put('objects/recipes/' + objectId, { "desired_servings" : servings},
function(result)
{
+ Grocy.Api.Post('recipes/' + objectId + '/add-not-fulfilled-products-to-shoppinglist', { },
+ function(result)
+ {
+ if (button.attr("data-recipe-type") == "normal")
+ {
+ button.addClass("disabled");
+ Grocy.FrontendHelpers.EndUiBusy();
+ }
+ else
+ {
+ window.location.reload();
+ }
+ },
+ function(xhr)
+ {
+ Grocy.FrontendHelpers.EndUiBusy();
+ console.error(xhr);
+ }
+ );
},
function(xhr)
{
console.error(xhr);
}
);
-
- Grocy.Api.Post('recipes/' + objectId + '/add-not-fulfilled-products-to-shoppinglist', { },
- function(result)
- {
- if (button.attr("data-recipe-type") == "normal")
- {
- button.addClass("disabled");
- Grocy.FrontendHelpers.EndUiBusy();
- }
- else
- {
- window.location.reload();
- }
- },
- function(xhr)
- {
- Grocy.FrontendHelpers.EndUiBusy();
- console.error(xhr);
- }
- );
}
}
});
@@ -690,34 +685,29 @@ $(document).on('click', '.recipe-consume-button', function(e)
{
Grocy.FrontendHelpers.BeginUiBusy();
- //set the recipes desired_servings so that the views resolve correctly
- //based on the meal plan servings
- var data = { };
- data.desired_servings = servings;
-
- Grocy.Api.Put('objects/recipes/' + objectId, data,
+ // Set the recipes desired_servings so that the "recipes resolved"-views resolve correctly based on the meal plan entry servings
+ Grocy.Api.Put('objects/recipes/' + objectId, { "desired_servings": servings },
function(result)
{
+ Grocy.Api.Post('recipes/' + objectId + '/consume', {},
+ function(result)
+ {
+ Grocy.FrontendHelpers.EndUiBusy();
+ toastr.success(__t('Removed all ingredients of recipe "%s" from stock', objectName));
+ },
+ function(xhr)
+ {
+ toastr.warning(__t('Not all ingredients of recipe "%s" are in stock, nothing removed', objectName));
+ Grocy.FrontendHelpers.EndUiBusy();
+ console.error(xhr);
+ }
+ );
},
function(xhr)
{
console.error(xhr);
}
);
-
- Grocy.Api.Post('recipes/' + objectId + '/consume', { },
- function(result)
- {
- Grocy.FrontendHelpers.EndUiBusy();
- toastr.success(__t('Removed all ingredients of recipe "%s" from stock', objectName));
- },
- function(xhr)
- {
- toastr.warning(__t('Not all ingredients of recipe "%s" are in stock, nothing removed', objectName));
- Grocy.FrontendHelpers.EndUiBusy();
- console.error(xhr);
- }
- );
}
}
});
@@ -732,37 +722,32 @@ $(document).on("click", ".recipe-popup-button", function(e)
var objectId = $(e.currentTarget).attr('data-recipe-id');
var servings = $(e.currentTarget).attr('data-mealplan-servings');
- //set the recipes desired_servings so that the views resolve correctly
- //based on the meal plan servings
- var data = { };
- data.desired_servings = servings;
-
- Grocy.Api.Put('objects/recipes/' + objectId, data,
+ // Set the recipes desired_servings so that the "recipes resolved"-views resolve correctly based on the meal plan entry servings
+ Grocy.Api.Put('objects/recipes/' + objectId, { "desired_servings": servings },
function(result)
{
+ bootbox.dialog({
+ message: '',
+ size: 'extra-large',
+ backdrop: true,
+ closeButton: false,
+ buttons: {
+ cancel: {
+ label: __t('Close'),
+ className: 'btn-secondary responsive-button',
+ callback: function ()
+ {
+ bootbox.hideAll();
+ }
+ }
+ }
+ });
},
function(xhr)
{
console.error(xhr);
}
);
-
- bootbox.dialog({
- message: '',
- size: 'extra-large',
- backdrop: true,
- closeButton: false,
- buttons: {
- cancel: {
- label: __t('Close'),
- className: 'btn-secondary responsive-button',
- callback: function()
- {
- bootbox.hideAll();
- }
- }
- }
- });
});
$(window).on("resize", function()