Added woolies search

This commit is contained in:
jableader 2024-01-17 19:45:23 +11:00
parent 1856db28be
commit 1820bf9492
3 changed files with 14 additions and 5 deletions

View file

@ -11,7 +11,12 @@
<a :href="ingredient?.product?.link" v-if="ingredient?.product?.link" target=_blank>
( {{ ingredient?.product?.name }} <img src="@/assets/external-link.svg" style="width: 1em; height: 1em; vertical-align: middle; margin-left: 0.5em; margin-bottom: 0.2em;" /> )
</a>
<span v-else>( {{ 'product' }} )</span>
<a v-else-if="ingredient?.name" :href="searchlink" target="_blank">
(search?)
</a>
<a v-else>
(product)
</a>
</span>
</div>
</template>
@ -21,6 +26,11 @@
export default {
name: 'CompactParsedIngredient',
props: ['ingredient'],
computed: {
searchlink() {
return 'https://www.woolworths.com.au/shop/search/products?searchTerm=' + encodeURIComponent(this.ingredient.name);
}
}
}
</script>
@ -38,7 +48,6 @@ export default {
margin: auto 0;
margin-right: 1em;
border-bottom: solid 1px #ccc;
padding-left: 0.5em;
}
.parse-element.missing {

View file

@ -3,8 +3,7 @@
<p class="ingredient-line">
<ingredient-line :ingredient="ingredient"
@update-ingredient="updateIngredient"
@update-product-link="updateProduct"
@delete-item="deleteIngredient" />
@update-product-link="updateProduct" />
</p>
<button @click="addIngredient(ingredient)">Add</button>
</div>

View file

@ -22,13 +22,14 @@ export default {
components: { CompactParsedIngredient },
data() {
return {
ingredientText: this.ingredient.line,
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,