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