Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor fix - compare products

KrzysztofPajak549f452eec93
diff --git a/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml b/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml
index 2a0b8150a..05f8a7f91 100644
--- a/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml
+++ b/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml
@@ -23,7 +23,7 @@
<div class="page compare-products-page">
<h2 class="text-center generalTitle">@Loc["Products.Compare.Title"]</h2>
<template v-if="compareproducts !== null && compareproducts.Products.length > 0">
- <a class="btn btn-danger mb-3" @@click="removeFromCompareList()">@Loc["Products.Compare.Clear"]</a>
+ <a class="btn btn-danger mb-3" @@click="removeFromCompareList(); getCompareList('@Url.RouteUrl("CompareProducts")')">@Loc["Products.Compare.Clear"]</a>
<div class="table-responsive">
<table class="table table-hover compare-products-table table-bordered">
<tbody>
@@ -31,7 +31,7 @@
<td class="empty">&nbsp;</td>
<template v-for="product in compareproducts.Products">
<td class="same-width">
- <button type="button" title="@Loc["Common.Remove"]" class="btn btn-sm btn-link remove-button d-flex align-items-center justify-content-center" @@click="removeFromCompareList(product.Id)">
+ <button type="button" title="@Loc["Common.Remove"]" class="btn btn-sm btn-link remove-button d-flex align-items-center justify-content-center" @@click="removeFromCompareList(product.Id); getCompareList('@Url.RouteUrl("CompareProducts")')">
<b-icon icon="trash" variant="danger" aria-hidden="true"></b-icon>
</button>
</td>
@@ -131,6 +131,6 @@
}),
})
document.addEventListener("DOMContentLoaded", function () {
- vm.getCompareList()
+ vm.getCompareList('@Url.RouteUrl("CompareProducts")')
})
</script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Shared/SidebarCompareProducts.cshtml b/src/Web/Grand.Web/Views/Shared/SidebarCompareProducts.cshtml
index f3836d593..9f2959936 100644
--- a/src/Web/Grand.Web/Views/Shared/SidebarCompareProducts.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/SidebarCompareProducts.cshtml
@@ -6,7 +6,7 @@
<ul class="px-0">
<li class="nav-item">
<a href="#" target="_self" class="nav-link">
- <b-icon icon="shuffle" :variant="[darkMode ? 'white' : 'dark']" @@click="getCompareList()" v-b-toggle.sidebar-compare></b-icon>
+ <b-icon icon="shuffle" :variant="[darkMode ? 'white' : 'dark']" @@click="getCompareList('@Url.RouteUrl("CompareProducts")')" v-b-toggle.sidebar-compare></b-icon>
<span class="qty-indicator">
{{compareProductsQty}}
</span>
@@ -30,7 +30,7 @@
<div class="price"><span>@Loc["Wishlist.Mini.UnitPrice"]:</span> <strong>{{product.ProductPrice.Price}}</strong></div>
</div>
<div>
- <a class="deleteitem" @@click="removeFromCompareList(product.Id)">
+ <a class="deleteitem" @@click="removeFromCompareList(product.Id); getCompareList('@Url.RouteUrl("CompareProducts")'); ">
<b-icon icon="trash" variant="danger"></b-icon>
</a>
</div>
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index 51625a057..a6460cad2 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -1,6 +1,6 @@
var vm = new Vue({
el: '#app',
- data: function() {
+ data: function () {
return {
show: false,
hover: false,
@@ -240,7 +240,7 @@
this.flycartitems = response.data.Items,
this.flycartindicator = response.data.TotalProducts,
this.flycartfirstload = false
- ))
+ ))
},
updateWishlist: function (url) {
axios({
@@ -259,26 +259,24 @@
this.wishindicator = response.data.Items.length
))
},
- getCompareList: function () {
- if (this.compareProductsQty > 0) {
- this.loader = true;
- axios({
- baseURL: '/compareproducts',
- method: 'get',
- params: {
- t: new Date().getTime()
- },
- data: null,
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
- }
- }).then(response => {
- this.loader = false;
- this.compareproducts = response.data
- })
- }
+ getCompareList: function (url) {
+ this.loader = true;
+ axios({
+ baseURL: url,
+ method: 'get',
+ params: {
+ t: new Date().getTime()
+ },
+ data: null,
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-Response-View': 'Json'
+ }
+ }).then(response => {
+ this.loader = false;
+ this.compareproducts = response.data
+ })
},
removeFromCompareList: function (id) {
if (id !== undefined) {
@@ -290,7 +288,6 @@
AxiosCart.setCookie('Grand.CompareProduct', '');
}
this.updateCompareProductsQty();
- this.getCompareList();
},
showModalOutOfStock: function () {
this.$refs['out-of-stock'].show()
@@ -527,6 +524,6 @@
}
}
},
-
+
},
});