catch empty lines in paste_ingredients
This commit is contained in:
parent
8b94bf1333
commit
d68a89a32c
@ -969,23 +969,24 @@ export default {
|
|||||||
appendIngredients: function () {
|
appendIngredients: function () {
|
||||||
let ing_list = this.paste_ingredients.split(/\r?\n/)
|
let ing_list = this.paste_ingredients.split(/\r?\n/)
|
||||||
let step = this.recipe.steps.findIndex((x) => x.id == this.paste_step)
|
let step = this.recipe.steps.findIndex((x) => x.id == this.paste_step)
|
||||||
let order = 0
|
let order = Math.max(...this.recipe.steps[step].ingredients.map((x) => x.order)) + 1
|
||||||
this.recipe.steps[step].ingredients_visible = true
|
this.recipe.steps[step].ingredients_visible = true
|
||||||
ing_list.forEach((ing) => {
|
ing_list.forEach((ing) => {
|
||||||
this.genericPostAPI("api_ingredient_from_string", { text: ing }).then((result) => {
|
if (ing.trim() !== "") {
|
||||||
let unit = null
|
this.genericPostAPI("api_ingredient_from_string", { text: ing }).then((result) => {
|
||||||
if (result.data.unit !== "") {
|
let unit = null
|
||||||
unit = { name: result.data.unit }
|
if (result.data.unit !== "") {
|
||||||
}
|
unit = { name: result.data.unit }
|
||||||
this.recipe.steps[step].ingredients.push({
|
}
|
||||||
amount: result.data.amount,
|
this.recipe.steps[step].ingredients.splice(order, 0, {
|
||||||
unit: unit,
|
amount: result.data.amount,
|
||||||
food: { name: result.data.food },
|
unit: unit,
|
||||||
note: result.data.note,
|
food: { name: result.data.food },
|
||||||
order: order,
|
note: result.data.note,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
order++
|
||||||
order++
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user