2024-01-13 02:00:15 +00:00
|
|
|
<template>
|
|
|
|
|
<div class="ingredient-item">
|
2024-01-17 06:37:57 +00:00
|
|
|
<p>
|
|
|
|
|
<input v-model="ingredientText" @keyup.enter="updateIngredient" @blur="updateIngredient" placeholder="Enter an ingredient" />
|
|
|
|
|
<input v-model="productLink" class="product-link-input" placeholder="Enter product link" @keyup.enter="updateProductLink" @blur="updateProductLink" />
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
<!-- Single line parse results -->
|
|
|
|
|
<compact-parsed-ingredient :ingredient="ingredient" />
|
|
|
|
|
</p>
|
2024-01-13 02:00:15 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-01-14 06:20:21 +00:00
|
|
|
import CompactParsedIngredient from './CompactParsedIngredient.vue';
|
2024-01-13 02:00:15 +00:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
2024-01-14 06:20:21 +00:00
|
|
|
ingredient: { type: Object },
|
2024-01-13 02:00:15 +00:00
|
|
|
},
|
|
|
|
|
events: ['update-ingredient', 'update-product-link'],
|
2024-01-14 06:20:21 +00:00
|
|
|
components: { CompactParsedIngredient },
|
2024-01-13 02:00:15 +00:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
ingredientText: this.ingredient.line,
|
2024-01-17 06:51:37 +00:00
|
|
|
productLink: this.ingredient.product?.link ?? "",
|
2024-01-13 02:00:15 +00:00
|
|
|
};
|
|
|
|
|
},
|
2024-01-17 06:51:37 +00:00
|
|
|
watch: {
|
|
|
|
|
ingredient: {
|
|
|
|
|
handler: function (newIngredient) {
|
|
|
|
|
this.productLink = newIngredient.product?.link ?? "";
|
|
|
|
|
},
|
|
|
|
|
deep: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-01-13 02:00:15 +00:00
|
|
|
methods: {
|
|
|
|
|
updateIngredient() {
|
|
|
|
|
if (this.ingredientText != this.ingredient.line)
|
|
|
|
|
this.$emit('update-ingredient', this.ingredient, this.ingredientText);
|
|
|
|
|
},
|
|
|
|
|
updateProductLink() {
|
|
|
|
|
if (this.productLink && this.productLink != this.ingredient.product?.link)
|
|
|
|
|
this.$emit('update-product-link', this.ingredient, this.productLink);
|
2024-01-14 02:12:19 +00:00
|
|
|
}
|
2024-01-13 02:00:15 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
2024-01-17 06:37:57 +00:00
|
|
|
input {
|
2024-01-13 02:00:15 +00:00
|
|
|
border: 0;
|
|
|
|
|
font-size: larger;
|
|
|
|
|
border-bottom: 1px solid #ccc;
|
|
|
|
|
border-left: 1px solid #ccc;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-14 01:46:45 +00:00
|
|
|
.product-link-input {
|
|
|
|
|
padding: 0.5vh;
|
|
|
|
|
color: #777;
|
2024-01-17 06:37:57 +00:00
|
|
|
margin-top: 0.5vh;
|
2024-01-13 02:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|