From 012dea5a0c5af5c23b147b488f7d310c5ae149c9 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 11 Feb 2023 11:57:52 +0100 Subject: [PATCH] fixed and improved import ingredient edit --- .../apps/ImportView/ImportViewStepEditor.vue | 47 ++++++++++++++++--- vue/src/locales/en.json | 2 +- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/vue/src/apps/ImportView/ImportViewStepEditor.vue b/vue/src/apps/ImportView/ImportViewStepEditor.vue index ec2caf49..11fd91e8 100644 --- a/vue/src/apps/ImportView/ImportViewStepEditor.vue +++ b/vue/src/apps/ImportView/ImportViewStepEditor.vue @@ -28,7 +28,7 @@ {{ i.unit.name }} {{ i.food.name }} {{ i.original_text }} - + @@ -62,25 +62,34 @@ - +
- + - - + + - + -
+ +
@@ -104,6 +113,7 @@ export default { return { recipe_json: undefined, current_edit_ingredient: null, + current_edit_step: null, } }, watch: { @@ -202,7 +212,30 @@ export default { found = true } }) + }, + /** + * Prepare variable that holds currently edited ingredient for modal to manipulate it + * add default placeholder for food/unit in case it is not present, so it can be edited as well + * @param ingredient + */ + prepareIngredientEditModal: function (step, ingredient) { + if (ingredient.unit === null) { + ingredient.unit = { + "name": "" + } + } + if (ingredient.food === null) { + ingredient.food = { + "name": "" + } + } + this.current_edit_ingredient = ingredient + this.current_edit_step = step + }, + removeIngredient: function (step, ingredient) { + step.ingredients = step.ingredients.filter((i) => i !== ingredient) } + } } diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json index 137c48b5..47ce0a5a 100644 --- a/vue/src/locales/en.json +++ b/vue/src/locales/en.json @@ -118,7 +118,7 @@ "Image": "Image", "Delete": "Delete", "Open": "Open", - "Ok": "Open", + "Ok": "Ok", "Save": "Save", "Step": "Step", "Search": "Search",