diff --git a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue index c0c8a2c0d..a76c7f051 100644 --- a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue +++ b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue @@ -1,5 +1,6 @@
+

{{ recipe.name }}

@@ -75,12 +76,12 @@ />
- + + + + + +
@@ -172,6 +173,7 @@ import IngredientsCard from "@/components/IngredientsCard" import StepComponent from "@/components/StepComponent" import KeywordsComponent from "@/components/KeywordsComponent" import NutritionComponent from "@/components/NutritionComponent" +import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher" Vue.prototype.moment = moment @@ -192,22 +194,32 @@ export default { KeywordsComponent, LoadingSpinner, AddRecipeToBook, + RecipeSwitcher, }, computed: { ingredient_factor: function () { return this.servings / this.recipe.servings }, + ingredient_count() { + return this.recipe?.steps.map((x) => x.ingredients).flat().length + }, }, data() { return { loading: true, recipe: undefined, - ingredient_count: 0, + rootrecipe: undefined, servings: 1, + servings_cache: {}, start_time: "", share_uid: window.SHARE_UID, } }, + watch: { + servings(newVal, oldVal) { + this.servings_cache[this.recipe.id] = this.servings + }, + }, mounted() { this.loadRecipe(window.RECIPE_ID) this.$i18n.locale = window.CUSTOM_LOCALE @@ -218,12 +230,9 @@ export default { if (window.USER_SERVINGS !== 0) { recipe.servings = window.USER_SERVINGS } - this.servings = recipe.servings let total_time = 0 for (let step of recipe.steps) { - this.ingredient_count += step.ingredients.length - for (let ingredient of step.ingredients) { this.$set(ingredient, "checked", false) } @@ -237,7 +246,8 @@ export default { this.start_time = moment().format("yyyy-MM-DDTHH:mm") } - this.recipe = recipe + this.recipe = this.rootrecipe = recipe + this.servings = this.servings_cache[this.rootrecipe.id] = recipe.servings this.loading = false }) }, @@ -253,6 +263,15 @@ export default { } } }, + quickSwitch: function (e) { + if (e === -1) { + this.recipe = this.rootrecipe + this.servings = this.servings_cache[this.rootrecipe?.id ?? 1] + } else { + this.recipe = e + this.servings = this.servings_cache?.[e.id] ?? e.servings + } + }, }, } diff --git a/vue/src/components/Buttons/RecipeSwitcher.vue b/vue/src/components/Buttons/RecipeSwitcher.vue new file mode 100644 index 000000000..607155655 --- /dev/null +++ b/vue/src/components/Buttons/RecipeSwitcher.vue @@ -0,0 +1,185 @@ + + + + + diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json index c718fe126..fcf49e540 100644 --- a/vue/src/locales/en.json +++ b/vue/src/locales/en.json @@ -280,5 +280,7 @@ "mark_complete": "Mark Complete", "QuickEntry": "Quick Entry", "shopping_add_onhand_desc": "Mark food 'On Hand' when checked off shopping list.", - "shopping_add_onhand": "Auto On Hand" + "shopping_add_onhand": "Auto On Hand", + "related_recipes": "Related Recipes", + "today_recipes": "Today's Recipes" }