Better display of parsed ingredients
This commit is contained in:
parent
494715f2a2
commit
bb52d9b121
2 changed files with 112 additions and 12 deletions
|
|
@ -16,7 +16,8 @@
|
||||||
<ingredient-line
|
<ingredient-line
|
||||||
:ingredient="ingredient"
|
:ingredient="ingredient"
|
||||||
@update-ingredient="updateIngredient"
|
@update-ingredient="updateIngredient"
|
||||||
@update-product-link="updateProduct" />
|
@update-product-link="updateProduct"
|
||||||
|
@delete-item="deleteIngredient" />
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<button class="submit-btn" @click="saveRecipe">Save</button>
|
<button class="submit-btn" @click="saveRecipe">Save</button>
|
||||||
|
|
@ -113,6 +114,9 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
deleteIngredient(ingredient) {
|
||||||
|
this.recipe.ingredients = this.recipe.ingredients.filter(i => i != ingredient);
|
||||||
|
},
|
||||||
saveRecipe() {
|
saveRecipe() {
|
||||||
data.saveRecipe(this.recipe).then((response) => {
|
data.saveRecipe(this.recipe).then((response) => {
|
||||||
this.$router.push(`/recipes/${response.id}`)
|
this.$router.push(`/recipes/${response.id}`)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,28 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Parse Results card -->
|
<div class="action_items">
|
||||||
<div class="ingredient-details" v-if="ingredient">
|
<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>
|
||||||
|
</div>
|
||||||
|
<!-- Details section -->
|
||||||
|
<div v-if="showDetails" class="details-section">
|
||||||
|
<div class="ingredient-details" v-if="ingredient && showDetails">
|
||||||
<div class="parse-result">
|
<div class="parse-result">
|
||||||
<p><small>Ingredient: </small><strong>{{ ingredient.name }}</strong></p>
|
<p><small>Ingredient: </small><strong>{{ ingredient.name }}</strong></p>
|
||||||
<p><small>Quantity: </small> <strong>{{ ingredient.quantity }}</strong></p>
|
<p><small>Quantity: </small> <strong>{{ ingredient.quantity }}</strong></p>
|
||||||
|
|
@ -27,6 +47,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Parse Results card -->
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -40,6 +64,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
ingredientText: this.ingredient.line,
|
ingredientText: this.ingredient.line,
|
||||||
productLink: this.ingredient.product?.link ?? "",
|
productLink: this.ingredient.product?.link ?? "",
|
||||||
|
showDetails: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -50,7 +75,10 @@ export default {
|
||||||
updateProductLink() {
|
updateProductLink() {
|
||||||
if (this.productLink && this.productLink != this.ingredient.product?.link)
|
if (this.productLink && this.productLink != this.ingredient.product?.link)
|
||||||
this.$emit('update-product-link', this.ingredient, this.productLink);
|
this.$emit('update-product-link', this.ingredient, this.productLink);
|
||||||
}
|
},
|
||||||
|
deleteItem() {
|
||||||
|
this.$emit('delete-item', this.ingredient);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -72,6 +100,74 @@ export default {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
.product_teaser img {
|
.product_teaser img {
|
||||||
max-width: 3em;
|
max-width: 3em;
|
||||||
max-height: 3em;
|
max-height: 3em;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue