From 22c978c8dcc0afde0a2fedd1ccc7f3afc22607ef Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 21 Jan 2020 21:42:52 +0100 Subject: [PATCH] Preselect the default serving size when adding a nested recipe (closes #500) --- public/viewjs/recipeform.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index 4bf417bd..2e2948b9 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -348,3 +348,23 @@ $(window).on("message", function(e) window.location.href = U('/recipe/' + Grocy.EditObjectId); } }); + +Grocy.Components.RecipePicker.GetPicker().on('change', function (e) +{ + var value = Grocy.Components.RecipePicker.GetValue(); + if (value.toString().isEmpty()) + { + return; + } + + Grocy.Api.Get('objects/recipes/' + value, + function(recipe) + { + $("#includes_servings").val(recipe.servings); + }, + function(xhr) + { + console.error(xhr); + } + ); +});