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

View file

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

View file

@ -22,13 +22,14 @@ export default {
components: { CompactParsedIngredient }, components: { CompactParsedIngredient },
data() { data() {
return { return {
ingredientText: this.ingredient.line, ingredientText: this.ingredient?.line ?? "",
productLink: this.ingredient.product?.link ?? "", productLink: this.ingredient.product?.link ?? "",
}; };
}, },
watch: { watch: {
ingredient: { ingredient: {
handler: function (newIngredient) { handler: function (newIngredient) {
this.ingredientText = newIngredient?.line ?? "";
this.productLink = newIngredient.product?.link ?? ""; this.productLink = newIngredient.product?.link ?? "";
}, },
deep: true, deep: true,