diff --git a/frontend/app/components/Domain/Recipe/RecipeDialogPrintPreferences.vue b/frontend/app/components/Domain/Recipe/RecipeDialogPrintPreferences.vue index b20dd2bed..681d6e063 100644 --- a/frontend/app/components/Domain/Recipe/RecipeDialogPrintPreferences.vue +++ b/frontend/app/components/Domain/Recipe/RecipeDialogPrintPreferences.vue @@ -78,6 +78,19 @@ /> + + + + + + + @@ -362,6 +388,27 @@ const hasNotes = computed(() => { return props.recipe.notes && props.recipe.notes.length > 0; }); +// Precompute each step's linked ingredients so the template doesn't re-filter recipeIngredient on every render +const stepLinkedIngredients = computed(() => { + const map = new Map(); + + instructionSections.value.forEach((section, sectionIndex) => { + section.instructions.forEach((step, stepIndex) => { + if (!step.ingredientReferences?.length) { + return; + } + + const referenceIds = new Set(step.ingredientReferences.map(ref => ref.referenceId)); + map.set( + `${sectionIndex}-${stepIndex}`, + props.recipe.recipeIngredient.filter(ing => ing.referenceId && referenceIds.has(ing.referenceId)), + ); + }); + }); + + return map; +}); + const { parseIngredientText } = useIngredientTextParser(); function parseText(ingredient: RecipeIngredient) { @@ -403,6 +450,13 @@ p { grid-gap: 0.5rem; } +.step-ingredient-grid { + display: grid; + grid-auto-flow: column; + grid-template-columns: 1fr 1fr; + grid-gap: 0.2rem; +} + .ingredient-title, .instruction-title { grid-column: 1 / span 2; diff --git a/frontend/app/composables/use-users/preferences.ts b/frontend/app/composables/use-users/preferences.ts index 401cf7e50..3fc21a125 100644 --- a/frontend/app/composables/use-users/preferences.ts +++ b/frontend/app/composables/use-users/preferences.ts @@ -6,6 +6,7 @@ import type { QueryFilterJSON } from "~/lib/api/types/non-generated"; export interface UserPrintPreferences { imagePosition: string; showDescription: boolean; + showLinkedIngredients: boolean; showNotes: boolean; showNutrition: boolean; expandChildRecipes: boolean; @@ -98,6 +99,7 @@ export function useUserPrintPreferences(): Ref { { imagePosition: "left" as ImagePosition, showDescription: true, + showLinkedIngredients: false, showNotes: true, showNutrition: false, expandChildRecipes: false, diff --git a/frontend/app/lang/messages/en-US.json b/frontend/app/lang/messages/en-US.json index 94d721214..c7e26581f 100644 --- a/frontend/app/lang/messages/en-US.json +++ b/frontend/app/lang/messages/en-US.json @@ -431,6 +431,7 @@ "milligrams": "milligrams", "note": "Note", "nutrition": "Nutrition", + "linked-ingredients": "Linked Ingredients", "original-url": "Original URL", "perform-time": "Cook Time", "prep-time": "Prep Time",