|
|
|
@ -36,7 +36,7 @@
|
|
|
|
<va-button v-else @click="removeFromCart">Убрать из корзины</va-button>
|
|
|
|
<va-button v-else @click="removeFromCart">Убрать из корзины</va-button>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<va-button @click="copyCart">Скопировать список образцов</va-button>
|
|
|
|
<va-button @click="copyCart">{{ copyCartText }}</va-button>
|
|
|
|
<va-button color="warning" @click="emptyCart">Очистить корзину</va-button>
|
|
|
|
<va-button color="warning" @click="emptyCart">Очистить корзину</va-button>
|
|
|
|
|
|
|
|
|
|
|
|
</va-card-actions>
|
|
|
|
</va-card-actions>
|
|
|
|
@ -72,6 +72,7 @@ export default {
|
|
|
|
"description",
|
|
|
|
"description",
|
|
|
|
],
|
|
|
|
],
|
|
|
|
itemsInCart: [],
|
|
|
|
itemsInCart: [],
|
|
|
|
|
|
|
|
cartListCopied: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
@ -82,6 +83,7 @@ export default {
|
|
|
|
.then(data => {
|
|
|
|
.then(data => {
|
|
|
|
this.itemsInCart.push(data);
|
|
|
|
this.itemsInCart.push(data);
|
|
|
|
localStorage.setItem("cart", JSON.stringify(this.itemsInCart));
|
|
|
|
localStorage.setItem("cart", JSON.stringify(this.itemsInCart));
|
|
|
|
|
|
|
|
this.cartListCopied = false;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((e) => console.log(e));
|
|
|
|
.catch((e) => console.log(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -90,13 +92,18 @@ export default {
|
|
|
|
const routeId = Number.parseInt(this.$route.params.id);
|
|
|
|
const routeId = Number.parseInt(this.$route.params.id);
|
|
|
|
this.itemsInCart = this.itemsInCart.filter(item => item.id !== routeId)
|
|
|
|
this.itemsInCart = this.itemsInCart.filter(item => item.id !== routeId)
|
|
|
|
localStorage.setItem("cart", JSON.stringify(this.itemsInCart));
|
|
|
|
localStorage.setItem("cart", JSON.stringify(this.itemsInCart));
|
|
|
|
|
|
|
|
this.cartListCopied = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
copyCart() {
|
|
|
|
copyCart() {
|
|
|
|
// TODO: actual copying logic
|
|
|
|
const textToCopy = this.itemsInCart
|
|
|
|
console.log("Copying item list from cart");
|
|
|
|
|
|
|
|
console.log("Text to copy: " + this.itemsInCart
|
|
|
|
|
|
|
|
.map(item => item.internal_id)
|
|
|
|
.map(item => item.internal_id)
|
|
|
|
.reduce((list, item_id) => list + "," + item_id))
|
|
|
|
.reduce((list, item_id) => list + "," + item_id)
|
|
|
|
|
|
|
|
navigator.clipboard.writeText(textToCopy)
|
|
|
|
|
|
|
|
.then(() => this.cartListCopied = true)
|
|
|
|
|
|
|
|
.catch(e => console.log("Error copying item list ("
|
|
|
|
|
|
|
|
+ textToCopy
|
|
|
|
|
|
|
|
+ ") from cart: "
|
|
|
|
|
|
|
|
+ e))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
emptyCart() {
|
|
|
|
emptyCart() {
|
|
|
|
this.itemsInCart = [];
|
|
|
|
this.itemsInCart = [];
|
|
|
|
@ -145,6 +152,9 @@ export default {
|
|
|
|
const routeId = Number.parseInt(this.$route.params.id);
|
|
|
|
const routeId = Number.parseInt(this.$route.params.id);
|
|
|
|
return this.itemsInCart.some(item => item.id === routeId)
|
|
|
|
return this.itemsInCart.some(item => item.id === routeId)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
copyCartText() {
|
|
|
|
|
|
|
|
return (this.cartListCopied ? 'Скопировано ✓✓' : 'Скопировать список образцов')
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|