mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
fix: Merge ingredient references when combining recipe steps in RecipePageInstructions.vue
This commit is contained in:
parent
d322abc1b4
commit
fc15523c9f
1 changed files with 13 additions and 0 deletions
|
@ -587,9 +587,22 @@ function mergeAbove(target: number, source: number) {
|
||||||
source,
|
source,
|
||||||
targetText: instructionList.value[target].text,
|
targetText: instructionList.value[target].text,
|
||||||
sourceText: instructionList.value[source].text,
|
sourceText: instructionList.value[source].text,
|
||||||
|
targetIngredientReferences: [...(instructionList.value[target].ingredientReferences || [])],
|
||||||
|
sourceIngredientReferences: [...(instructionList.value[source].ingredientReferences || [])],
|
||||||
});
|
});
|
||||||
|
|
||||||
instructionList.value[target].text += " " + instructionList.value[source].text;
|
instructionList.value[target].text += " " + instructionList.value[source].text;
|
||||||
|
|
||||||
|
const targetRefs = instructionList.value[target].ingredientReferences || [];
|
||||||
|
const sourceRefs = instructionList.value[source].ingredientReferences || [];
|
||||||
|
const mergedRefsMap = new Map();
|
||||||
|
[...targetRefs, ...sourceRefs].forEach(ref => {
|
||||||
|
if (ref.referenceId) {
|
||||||
|
mergedRefsMap.set(ref.referenceId, ref);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
instructionList.value[target].ingredientReferences = Array.from(mergedRefsMap.values());
|
||||||
|
|
||||||
instructionList.value.splice(source, 1);
|
instructionList.value.splice(source, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue