From ce02a23dbb03ef1270338c9e476169a2ab6c9615 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Thu, 29 Jun 2023 17:13:53 +0200 Subject: [PATCH] fixed quick ingredient import in recipe editor --- vue/src/apps/RecipeEditView/RecipeEditView.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vue/src/apps/RecipeEditView/RecipeEditView.vue b/vue/src/apps/RecipeEditView/RecipeEditView.vue index 74695842d..4315867d3 100644 --- a/vue/src/apps/RecipeEditView/RecipeEditView.vue +++ b/vue/src/apps/RecipeEditView/RecipeEditView.vue @@ -1254,23 +1254,28 @@ export default { ing_list.forEach((ing) => { if (ing.trim() !== "") { promises.push(this.genericPostAPI("api_ingredient_from_string", {text: ing}).then((result) => { + let unit = null if (result.data.unit !== "" && result.data.unit !== null) { unit = {name: result.data.unit} } - parsed_ing_list.push({ + let new_ingredient = { amount: result.data.amount, unit: unit, food: {name: result.data.food}, note: result.data.note, original_text: ing, - }) + } + console.log(ing, new_ingredient) + parsed_ing_list.push(new_ingredient) })) } }) Promise.allSettled(promises).then(() => { ing_list.forEach(ing => { - step.ingredients.push(parsed_ing_list.find(x => x.original_text === ing)) + if(ing.trim() !== ""){ + step.ingredients.push(parsed_ing_list.find(x => x.original_text === ing)) + } }) }) },