From a431031c04a3dc25b5b14953c0f99a7f30024edc Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 13 Jan 2021 20:12:20 +0100 Subject: [PATCH] ingredient checking --- vue/src/apps/RecipeView/RecipeView.vue | 27 ++++++++++++++++++++------ vue/src/components/Ingredient.vue | 10 ++++++++-- vue/src/components/Step.vue | 2 +- vue/webpack-stats.json | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue index e72b3005..09b797b4 100644 --- a/vue/src/apps/RecipeView/RecipeView.vue +++ b/vue/src/apps/RecipeView/RecipeView.vue @@ -85,7 +85,8 @@ @@ -126,7 +127,7 @@
+ @update-start-time="updateStartTime" @checked-state-changed="updateIngredientCheckedState">
@@ -185,13 +186,15 @@ export default { methods: { loadRecipe: function (recipe_id) { apiLoadRecipe(recipe_id).then(recipe => { - this.recipe = recipe - this.loading = false let total_time = 0 - for (let step of this.recipe.steps) { + for (let step of recipe.steps) { this.ingredient_count += step.ingredients.length + for (let ingredient of step.ingredients) { + this.$set(ingredient, 'checked', false) + } + step.time_offset = total_time total_time += step.time } @@ -200,11 +203,23 @@ export default { if (total_time > 0) { this.start_time = moment().format('yyyy-MM-DDTHH:mm') } + + this.recipe = recipe + this.loading = false }) }, updateStartTime: function (e) { this.start_time = e - } + }, + updateIngredientCheckedState: function (e) { + for (let step of this.recipe.steps) { + for (let ingredient of step.ingredients) { + if (ingredient.id === e.id) { + this.$set(ingredient, 'checked', !ingredient.checked) + } + } + } + }, } } diff --git a/vue/src/components/Ingredient.vue b/vue/src/components/Ingredient.vue index cdafcbf5..735126ae 100644 --- a/vue/src/components/Ingredient.vue +++ b/vue/src/components/Ingredient.vue @@ -1,7 +1,8 @@