2024-01-14 02:12:19 +00:00
|
|
|
<template>
|
2024-01-14 06:20:21 +00:00
|
|
|
<div class="ingredient-add-box">
|
|
|
|
|
<p class="ingredient-line">
|
|
|
|
|
<ingredient-line :ingredient="ingredient"
|
|
|
|
|
@update-ingredient="updateIngredient"
|
2024-01-17 08:45:23 +00:00
|
|
|
@update-product-link="updateProduct" />
|
2024-01-14 06:20:21 +00:00
|
|
|
</p>
|
|
|
|
|
<button @click="addIngredient(ingredient)">Add</button>
|
2024-01-14 02:12:19 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-05-04 02:49:32 +00:00
|
|
|
import IngredientLine from '@/components/ingredients/IngredientLine.vue';
|
2024-01-14 02:12:19 +00:00
|
|
|
import data from '@/data.js'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'IngredientAddBox',
|
|
|
|
|
components: { IngredientLine },
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2024-01-17 06:37:57 +00:00
|
|
|
ingredient: {},
|
2024-01-14 02:12:19 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
addIngredient() {
|
|
|
|
|
this.$emit('add-ingredient', this.ingredient);
|
2024-01-17 06:37:57 +00:00
|
|
|
this.ingredient = {};
|
2024-01-14 02:12:19 +00:00
|
|
|
},
|
2024-01-17 09:17:22 +00:00
|
|
|
async updateProduct(ingredient, product_link) {
|
|
|
|
|
this.ingredient.product = await data.parseProduct(ingredient, product_link);
|
2024-01-14 02:12:19 +00:00
|
|
|
},
|
2024-01-17 09:17:22 +00:00
|
|
|
async updateIngredient(ingredient, line) {
|
|
|
|
|
const newIngredients = await data.parseIngredients([line]);
|
|
|
|
|
this.ingredient = newIngredients[0];
|
2024-01-14 02:12:19 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2024-01-14 06:20:21 +00:00
|
|
|
|
|
|
|
|
.ingredient-add-box {
|
|
|
|
|
display: flex;
|
2024-01-17 06:37:57 +00:00
|
|
|
flex-direction: column;
|
2024-01-14 06:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ingredient-line {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-14 02:12:19 +00:00
|
|
|
</style>
|