1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 15:49:42 +02:00

feat: Insert instruction step above or below. #3731 (#3732)

This commit is contained in:
Jonathan Beaulieu 2024-06-18 06:45:12 -07:00 committed by GitHub
parent 82d930e645
commit 20b1b3de35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 44 additions and 0 deletions

View file

@ -22,6 +22,8 @@
class="list-group-item"
:disable-amount="recipe.settings.disableAmount"
@delete="recipe.recipeIngredient.splice(index, 1)"
@insert-above="insertNewIngredient(index)"
@insert-below="insertNewIngredient(index+1)"
/>
</TransitionGroup>
</draggable>
@ -140,6 +142,20 @@ export default defineComponent({
}
}
function insertNewIngredient(dest: number) {
props.recipe.recipeIngredient.splice(dest, 0, {
referenceId: uuid4(),
title: "",
note: "",
// @ts-expect-error - prop can be null-type by NoUndefinedField type forces it to be set
unit: undefined,
// @ts-expect-error - prop can be null-type by NoUndefinedField type forces it to be set
food: undefined,
disableAmount: true,
quantity: 1,
});
}
return {
user,
groupSlug,
@ -148,6 +164,7 @@ export default defineComponent({
hasFoodOrUnit,
imageKey,
drag,
insertNewIngredient,
};
},
});