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.

Fix catalog-filters

KrzysztofPajakbca600036034
diff --git a/src/Web/Grand.Web/Views/Catalog/_Filtering.cshtml b/src/Web/Grand.Web/Views/Catalog/_Filtering.cshtml
index 7f86990d6..ebc52591d 100644
--- a/src/Web/Grand.Web/Views/Catalog/_Filtering.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/_Filtering.cshtml
@@ -46,7 +46,7 @@
<div class="d-inline-flex flex-wrap w-100">
<template v-for="spec in group">
- <b-link class="d-flex align-items-center mr-2 mb-2 pb-0" @@click="catalog.loadProducts(spec.FilterUrl, true)">{{spec.SpecificationAttributeOptionName}}<b-icon class="ml-2 text-danger" icon="x-circle-fill"></b-icon></b-link>
+ <b-link class="d-flex align-items-center mr-2 mb-2 pb-0" @@click="catalog.loadProducts(spec.FilterUrl)">{{spec.SpecificationAttributeOptionName}}<b-icon class="ml-2 text-danger" icon="x-circle-fill"></b-icon></b-link>
</template>
</div>
@@ -54,7 +54,7 @@
</template>
</ul>
<div class="remove-filter">
- <b-button size="sm" variant="danger" @@click="catalog.loadProducts(catalog.Model.PagingFilteringContext.SpecificationFilter.RemoveFilterUrl, true)">
+ <b-button size="sm" variant="danger" @@click="catalog.loadProducts(catalog.Model.PagingFilteringContext.SpecificationFilter.RemoveFilterUrl)">
@Loc["Filtering.SpecificationFilter.Remove"]
</b-button>
</div>
diff --git a/src/Web/Grand.Web/Views/Catalog/_ModelScript.cshtml b/src/Web/Grand.Web/Views/Catalog/_ModelScript.cshtml
index 0d93cbc04..b37985fa1 100644
--- a/src/Web/Grand.Web/Views/Catalog/_ModelScript.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/_ModelScript.cshtml
@@ -8,64 +8,37 @@
}
},
methods: {
- loadProducts(url, remove) {
- var addurl = '';
- var state = null;
-
- if ((!(url.includes('updated')) && url.includes('?'))) {
- addurl = '&updated=1';
- state = { 'updated': 1 };
- }
-
- const Url = new URL(url);
- Url.searchParams.delete('updated');
-
- if (addurl == '' && Url.searchParams.get('updated') == null) {
- addurl = '&updated=1';
- }
-
- if (remove == true) {
- addurl = '?updated=1';
- }
-
- window.history.pushState(state, null, Url + addurl);
-
- catalog.getResponse(Url);
+ loadProducts(url) {
+ catalog.getResponse(url);
+ //set state
+ var stateurl = new URL(url);
+ stateurl.searchParams.delete('timestamp');
+ window.history.replaceState({ path: stateurl.href }, '', stateurl.href);
},
getResponse(url) {
- axios({
- url: url,
- method: 'get',
- data: null,
+ url = new URL(url);
+ url.searchParams.set('timestamp', new Date().getTime());
+ const options = {
headers: {
- 'Cache-Control': 'no-cache, no-store',
- 'Vary': 'Accept',
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Response-View': 'Json'
}
- }).then(function (response) {
- catalog.Model = response.data;
- });
+ };
+ axios.get(url, options)
+ .then(response => {
+ catalog.Model = response.data;
+ })
+ .catch(err => {
+ console.log(`${err} whilst contacting the catalog page.`)
+ });
},
goToPage(page) {
-
- let urlParams = new URLSearchParams(window.location.search);
- urlParams.set('pagenumber', page);
-
- urlParams.delete('updated');
-
- let exitUrl = document.location.origin + document.location.pathname + "?" + urlParams.toString();
-
- catalog.loadProducts(exitUrl);
-
+ let urlPagenumber = new URL(window.location.href);
+ urlPagenumber.searchParams.set('pagenumber', page);
+ catalog.loadProducts(urlPagenumber.href);
},
- historyWatch() {
- window.addEventListener('popstate', function (e) {
- var url = document.location.href;
- catalog.getResponse(url);
- })
- }
+
},
watch: {
Model: function(val) {
@@ -111,7 +84,6 @@
},
mounted() {
this.Model = @Model;
- this.historyWatch();
}
});
var catalog = new Catalog().$mount('#catalog-products');