From bb52d9b12196e7baf458f2aeec8c6eb41cf8bfa5 Mon Sep 17 00:00:00 2001 From: jableader Date: Sat, 13 Jan 2024 17:36:02 +1100 Subject: [PATCH] Better display of parsed ingredients --- src/components/EditRecipePage.vue | 6 +- src/components/IngredientLine.vue | 118 +++++++++++++++++++++++++++--- 2 files changed, 112 insertions(+), 12 deletions(-) diff --git a/src/components/EditRecipePage.vue b/src/components/EditRecipePage.vue index 9ea98f6..953677e 100644 --- a/src/components/EditRecipePage.vue +++ b/src/components/EditRecipePage.vue @@ -16,7 +16,8 @@ + @update-product-link="updateProduct" + @delete-item="deleteIngredient" /> @@ -113,6 +114,9 @@ export default { } }); }, + deleteIngredient(ingredient) { + this.recipe.ingredients = this.recipe.ingredients.filter(i => i != ingredient); + }, saveRecipe() { data.saveRecipe(this.recipe).then((response) => { this.$router.push(`/recipes/${response.id}`) diff --git a/src/components/IngredientLine.vue b/src/components/IngredientLine.vue index 96549f4..0c1f2b6 100644 --- a/src/components/IngredientLine.vue +++ b/src/components/IngredientLine.vue @@ -13,19 +13,43 @@

- -
-
-

Ingredient: {{ ingredient.name }}

-

Quantity: {{ ingredient.quantity }}

-

Unit: {{ ingredient.unit }}

-

Preparation: {{ ingredient.preparation }}

+
+
+ +
+ {{ ingredient?.quantity || 'qty' }} + {{ ingredient?.unit || 'unit' }} + of + {{ ingredient?.name || 'name' }} + ({{ ingredient?.product?.name || 'product' }}) +
+ + + + + +
-
-

Product: {{ ingredient.product.name }}

-

+ +
+
+
+

Ingredient: {{ ingredient.name }}

+

Quantity: {{ ingredient.quantity }}

+

Unit: {{ ingredient.unit }}

+

Preparation: {{ ingredient.preparation }}

+
+
+

Product: {{ ingredient.product.name }}

+

+
+
+ +
@@ -40,6 +64,7 @@ export default { return { ingredientText: this.ingredient.line, productLink: this.ingredient.product?.link ?? "", + showDetails: false }; }, methods: { @@ -50,7 +75,10 @@ export default { updateProductLink() { if (this.productLink && this.productLink != this.ingredient.product?.link) this.$emit('update-product-link', this.ingredient, this.productLink); - } + }, + deleteItem() { + this.$emit('delete-item', this.ingredient); + }, } }; @@ -72,6 +100,74 @@ export default { 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 { max-width: 3em; max-height: 3em;