2024-01-13 02:00:15 +00:00
|
|
|
<template>
|
|
|
|
|
<div class="ingredient-item">
|
|
|
|
|
<!-- Full ingredient line text bar -->
|
|
|
|
|
<div class="full-ingredient">
|
|
|
|
|
<p class="product_teaser" style="flex: initial" v-if="ingredient.product && ingredient.product.img_small">
|
|
|
|
|
<img :src="ingredient.product.img_small" />
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
<input v-model="ingredientText" @keyup.enter="updateIngredient" @focusout="updateIngredient" placeholder="Enter an ingredient" />
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
<input v-model="productLink" placeholder="Enter product link" @keyup.enter="updateProductLink" @focusout="updateProductLink" />
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-01-13 06:36:02 +00:00
|
|
|
<div class="action_items">
|
|
|
|
|
<div class="action-bar">
|
|
|
|
|
<!-- Single line parse results -->
|
|
|
|
|
<div class="compact-parse-results">
|
|
|
|
|
<span class="parse-element quantity" :class="{ missing: !(ingredient?.quantity)}">{{ ingredient?.quantity || 'qty' }}</span>
|
|
|
|
|
<span class="parse-element unit" :class="{ missing: !(ingredient?.unit)}">{{ ingredient?.unit || 'unit' }}</span>
|
|
|
|
|
of
|
|
|
|
|
<span class="parse-element name" :class="{ missing: !(ingredient?.name)}">{{ ingredient?.name || 'name' }}</span>
|
|
|
|
|
<span class="parse-element product-name" :class="{missing: !(ingredient?.product)}">({{ ingredient?.product?.name || 'product' }})</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Delete button -->
|
|
|
|
|
<button class="delete-button" @click="deleteItem">Delete</button>
|
|
|
|
|
|
|
|
|
|
<!-- Expand details button with animated chevron -->
|
|
|
|
|
<button class="expand-button" @click="showDetails = !showDetails">
|
|
|
|
|
<span :class="{'rotate-chevron': showDetails}">▾</span>
|
|
|
|
|
</button>
|
2024-01-13 02:00:15 +00:00
|
|
|
</div>
|
2024-01-13 06:36:02 +00:00
|
|
|
<!-- Details section -->
|
|
|
|
|
<div v-if="showDetails" class="details-section">
|
|
|
|
|
<div class="ingredient-details" v-if="ingredient && showDetails">
|
|
|
|
|
<div class="parse-result">
|
|
|
|
|
<p><small>Ingredient: </small><strong>{{ ingredient.name }}</strong></p>
|
|
|
|
|
<p><small>Quantity: </small> <strong>{{ ingredient.quantity }}</strong></p>
|
|
|
|
|
<p><small>Unit: </small> <strong>{{ ingredient.unit }}</strong></p>
|
|
|
|
|
<p><small>Preparation: </small> <strong>{{ ingredient.preparation }}</strong></p>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="ingredient.product" class="product-result">
|
|
|
|
|
<p><small>Product: </small><strong>{{ ingredient.product.name }}</strong></p>
|
|
|
|
|
<p><img :src="ingredient.product.img_small" /></p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-01-13 02:00:15 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-01-13 06:36:02 +00:00
|
|
|
|
|
|
|
|
<!-- Parse Results card -->
|
2024-01-13 02:00:15 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
ingredient: { type: Object }
|
|
|
|
|
},
|
|
|
|
|
events: ['update-ingredient', 'update-product-link'],
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
ingredientText: this.ingredient.line,
|
|
|
|
|
productLink: this.ingredient.product?.link ?? "",
|
2024-01-13 06:36:02 +00:00
|
|
|
showDetails: false
|
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-13 06:36:02 +00:00
|
|
|
},
|
|
|
|
|
deleteItem() {
|
|
|
|
|
this.$emit('delete-item', this.ingredient);
|
|
|
|
|
},
|
2024-01-13 02:00:15 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
.ingredient-item {
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.full-ingredient {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
text-align: left;
|
|
|
|
|
padding-left: 1em;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-13 06:36:02 +00:00
|
|
|
.action-bar {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: right;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.compact-parse-results {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
flex: 1;
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.parse-element {
|
|
|
|
|
margin-right: 1em;
|
|
|
|
|
border-bottom: solid 1px #ccc;
|
|
|
|
|
padding: 0.5em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.parse-element.missing {
|
|
|
|
|
color: red;
|
|
|
|
|
border: solid red 1px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.quantity {
|
|
|
|
|
color: blue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.unit {
|
|
|
|
|
color: green;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.name {
|
|
|
|
|
color: black;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
color: purple;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.delete-button,
|
|
|
|
|
.expand-button {
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
margin: 0 5px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.expand-button {
|
|
|
|
|
background-color: #f0f0f0;
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.rotate-chevron {
|
|
|
|
|
transform: rotate(180deg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.details-section {
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-13 02:00:15 +00:00
|
|
|
.product_teaser img {
|
|
|
|
|
max-width: 3em;
|
|
|
|
|
max-height: 3em;
|
|
|
|
|
margin-right: 1em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.full-ingredient p {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.full-ingredient input {
|
|
|
|
|
border: 0;
|
|
|
|
|
font-size: larger;
|
|
|
|
|
border-bottom: 1px solid #ccc;
|
|
|
|
|
border-left: 1px solid #ccc;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ingredient-details {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
text-align: left;
|
|
|
|
|
padding-left: 1em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.parse-result {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.product-result {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|