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.

displayBarNotification - message

DanielŻuławskia491df11635c
diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
index 6a801260e..a06108a60 100644
--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
@@ -15583,7 +15583,7 @@
<Value>The product has been added to your product comparison</Value>
</Resource>
<Resource Name="Products.ProductHasBeenAddedToCompareList.Link">
- <Value><![CDATA[The product has been added to your <a href="{0}">product comparison</a>]]></Value>
+ <Value>The product has been added to your product comparison</Value>
</Resource>
<Resource Name="Products.ProductHasBeenAddedToTheCart">
<Value>The product has been added to your shopping cart</Value>
diff --git a/src/Web/Grand.Web/Views/Catalog/_CatalogProductListView.cshtml b/src/Web/Grand.Web/Views/Catalog/_CatalogProductListView.cshtml
index 22af80f43..91b9846bd 100644
--- a/src/Web/Grand.Web/Views/Catalog/_CatalogProductListView.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/_CatalogProductListView.cshtml
@@ -288,7 +288,7 @@
}
@if (!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == ProductType.SimpleProduct)
{
- <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@string.Format(Loc["Products.ProductHasBeenAddedToCompareList.Link"], Url.RouteUrl("CompareProducts"))')">
+ <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@Loc["Products.ProductHasBeenAddedToCompareList.Link"]', '@Url.RouteUrl("CompareProducts")')">
<span class="sr-only">AddToCompareList</span>
<b-icon icon="shuffle"></b-icon>
</button>
diff --git a/src/Web/Grand.Web/Views/Catalog/_CatalogProductListViewVue.cshtml b/src/Web/Grand.Web/Views/Catalog/_CatalogProductListViewVue.cshtml
index 8b52de5b1..16915d949 100644
--- a/src/Web/Grand.Web/Views/Catalog/_CatalogProductListViewVue.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/_CatalogProductListViewVue.cshtml
@@ -226,7 +226,7 @@
</template>
</template>
<template v-if="!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == 0">
- <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@string.Format(Loc["Products.ProductHasBeenAddedToCompareList.Link"], Url.RouteUrl("CompareProducts"))`)'">
+ <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@Loc["Products.ProductHasBeenAddedToCompareList.Link"]`, `@Url.RouteUrl("CompareProducts")`)'">
<span class="sr-only">AddToCompareList</span>
<b-icon icon="shuffle"></b-icon>
</button>
diff --git a/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml b/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml
index f1fba9474..c111af5c3 100644
--- a/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml
+++ b/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml
@@ -4,7 +4,7 @@
}
@if (Model.CompareProductsEnabled)
{
- <button class="btn btn-secondary add-to-compare-list-button mr-1" type="button" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@string.Format(Loc["Products.ProductHasBeenAddedToCompareList.Link"], Url.RouteUrl("CompareProducts"))')" v-b-tooltip.hover.bottom title="@Loc["Products.Compare.AddToCompareList"]">
+ <button class="btn btn-secondary add-to-compare-list-button mr-1" type="button" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@Loc["Products.ProductHasBeenAddedToCompareList.Link"]', '@Url.RouteUrl("CompareProducts")')" v-b-tooltip.hover.bottom title="@Loc["Products.Compare.AddToCompareList"]">
<b-icon icon="shuffle"></b-icon>
<span class="sr-only">@Loc["Products.Compare.AddToCompareList"]</span>
</button>
diff --git a/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml b/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml
index 6644b0c4a..9b0688bbc 100644
--- a/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml
@@ -290,7 +290,7 @@
}
@if (!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == ProductType.SimpleProduct)
{
- <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@string.Format(Loc["Products.ProductHasBeenAddedToCompareList.Link"], Url.RouteUrl("CompareProducts"))')">
+ <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@Loc["Products.ProductHasBeenAddedToCompareList.Link"]', '@Url.RouteUrl("CompareProducts")')">
<span class="sr-only">AddToCompareList</span>
<b-icon icon="shuffle"></b-icon>
</button>
diff --git a/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml b/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml
index 274d01c8a..1f817d1e4 100644
--- a/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml
@@ -227,7 +227,7 @@
</template>
</template>
<template v-if="!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == 0">
- <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@string.Format(Loc["Products.ProductHasBeenAddedToCompareList.Link"], Url.RouteUrl("CompareProducts"))`)'">
+ <button v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@Loc["Products.ProductHasBeenAddedToCompareList.Link"]`, `@Url.RouteUrl("CompareProducts")`)'">
<span class="sr-only">AddToCompareList</span>
<b-icon icon="shuffle"></b-icon>
</button>
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index ee1ad0597..2753ae29d 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -45,6 +45,23 @@
}
},
methods: {
+ displayBarNotification(message, url, messagetype, timeout) {
+ var variant;
+
+ if (messagetype == 'error') {
+ variant = "danger";
+ } else {
+ variant = "info";
+ }
+
+ this.$bvToast.toast(message, {
+ title: messagetype,
+ variant: variant,
+ href: url,
+ autoHideDelay: timeout,
+ solid: true
+ })
+ },
deletecartitem: function (href) {
axios({
method: "post",
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
index d30e74704..b9e5a564c 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
@@ -136,7 +136,7 @@ var AxiosCart = {
});
},
//add a product to compare list
- addproducttocomparelist: function (id, message) {
+ addproducttocomparelist: function (id, message, url) {
if (this.loadWaiting != false) {
return;
}
@@ -153,7 +153,7 @@ var AxiosCart = {
this.setCookie('Grand.CompareProduct', cookie);
vm.updateCompareProductsQty();
- displayBarNotification(message, 'success', 3500);
+ vm.displayBarNotification(message, url, 'success', 3500);
this.resetLoadWaiting();
@@ -179,15 +179,6 @@ var AxiosCart = {
vm.flycartindicator = newfly.TotalProducts;
}
- //if (response.data.comparemessage) {
- // if (response.data.success == true) {
- // displayBarNotification(response.data.comparemessage, 'success', 3500);
- // }
- // else {
- // displayBarNotification(response.data.comparemessage, 'error', 3500);
- // }
- // return false;
- //}
if (response.data.product) {
if (response.data.success == true) {
@@ -228,7 +219,7 @@ var AxiosCart = {
}
else {
//error
- displayBarNotification(response.data.message, 'error', 3500);
+ vm.displayBarNotification(response.data.message, '', 'error', 3500);
}
return false;
}
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.common.js b/src/Web/Grand.Web/wwwroot/theme/script/public.common.js
index 17af308c5..d75f76c73 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.common.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.common.js
@@ -71,27 +71,6 @@ function displayPopupNewsletterCategory(html) {
});
}
-
-function displayBarNotification(message, messagetype, timeout) {
- if (messagetype == 'error') {
- toastHTML = '<b-toast id="grandToast" auto-hide-delay=' + timeout +' variant="danger" title=' + messagetype +'>'+ message +'</b-toast>'
- } else {
- toastHTML = '<b-toast id="grandToast" auto-hide-delay=' + timeout +' variant="info" title=' + messagetype+'>' + message + '</b-toast>'
- }
- document.querySelector('.modal-place').innerHTML = toastHTML;
- new Vue({
- el: ".modal-place",
- methods: {
- toast: function () {
- this.$bvToast.show('grandToast')
- }
- },
- mounted: function () {
- this.toast();
- }
- });
-}
-
// CSRF (XSRF) security
function addAntiForgeryToken(data) {
//if the object is undefined, create a new one.