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.

PopupAddToCart - changed to vue template

DanielŻuławski34b7bde4dfa5
diff --git a/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml b/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml
index 1429d3372..3bf294e09 100644
--- a/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml
@@ -38,4 +38,5 @@
<div id="bar-notification" class="generalNote"></div>
<div class="modal-place"></div>
-@await Component.InvokeAsync("PopupAction")
\ No newline at end of file
+<partial name="_PopupAddToCartVue" />
+@await Component.InvokeAsync("PopupAction")
diff --git a/src/Web/Grand.Web/Views/Shared/_PopupAddToCart.cshtml b/src/Web/Grand.Web/Views/Shared/_PopupAddToCartVue.cshtml
similarity index 53%
rename from src/Web/Grand.Web/Views/Shared/_PopupAddToCart.cshtml
rename to src/Web/Grand.Web/Views/Shared/_PopupAddToCartVue.cshtml
index 53028ab9f..23d4b4f9e 100644
--- a/src/Web/Grand.Web/Views/Shared/_PopupAddToCart.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_PopupAddToCartVue.cshtml
@@ -1,80 +1,54 @@
-@model AddToCartModel
-@{
- string text = "";
- if (Model.CartType == ShoppingCartType.ShoppingCart)
- {
- text = string.Format(Loc["AddToCart.Cart.Items"], Model.TotalItems);
- }
- else if (Model.CartType == ShoppingCartType.Wishlist)
- {
- text = string.Format(Loc["AddToCart.Wishlist.Items"], Model.TotalItems);
- }
- else if (Model.CartType == ShoppingCartType.Auctions)
- {
- text = string.Format(Loc["Addtocart.Auctions.Ongoing"], Model.TotalItems);
- }
-}
- <b-modal ref="ModalAddToCart" id="ModalAddToCart" :dark-theme="darkMode" body-class="p-0" size="lg" @@shown="onShown" centered hide-footer hide-header>
+<b-modal id="ModalAddToCart" ref="ModalAddToCart" :dark-theme="darkMode" body-class="p-0" size="lg" centered hide-footer hide-header>
+ <template v-if="PopupAddToCartVueModal !== null">
<button class="modal-close btn text-white" @@click="$bvModal.hide('ModalAddToCart')"><b-icon icon="x"></b-icon></button>
<div class="card" header-tag="header" footer-tag="footer" header-bg-variant="info" footer-bg-variant="white" footer-class="border-0">
<div class="card-header bg-info">
<h5 class="mb-0 text-white">
- @if (Model.CartType == ShoppingCartType.ShoppingCart || Model.CartType == ShoppingCartType.OnHoldCart)
- {
+ <template v-if="PopupAddToCartVueModal.CartType == 1 || PopupAddToCartVueModal.CartType == 0">
@Loc["AddToCart.ShoppingCart"]
- }
- else if (Model.CartType == ShoppingCartType.Wishlist)
- {
+ </template>
+ <template v-else-if="PopupAddToCartVueModal.CartType == 2">
@Loc["AddToCart.Wishlist"]
- }
- else if (Model.CartType == ShoppingCartType.Auctions)
- {
+ </template>
+ <template v-else-if="PopupAddToCartVueModal.CartType == 3">
@Loc["shoppingcart.yourbidhasbeenplaced"]
- }
+ </template>
</h5>
</div>
<div class="card-body">
<div class="col-12 px-0">
<div class="form-row">
<div class="d-sm-block d-none p-2">
- <img src="@Model.Picture.ImageUrl" alt="@Model.Picture.AlternateText" title="@Model.Picture.Title" />
+ <img :src="PopupAddToCartVueModal.Picture.ImageUrl" :alt="PopupAddToCartVueModal.Picture.AlternateText" :title="PopupAddToCartVueModal.Picture.Title" />
</div>
<div>
- <a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })"><h4>@Model.ProductName</h4></a>
- @if (!string.IsNullOrEmpty(Model.AttributeDescription))
- {
+ <a :href="'/' + PopupAddToCartVueModal.ProductSeName"><h4>{{PopupAddToCartVueModal.ProductName}}</h4></a>
+ <template v-if="PopupAddToCartVueModal.AttributeDescription !== ''">
<div class="form-group col-12 px-0 d-none d-md-block my-2">
<label class="w-100 mb-0"><strong>@Loc["AddToCart.Attributes"]</strong></label>
- <div class="attributes p-2">
- @Html.Raw(Model.AttributeDescription)
+ <div class="attributes p-2" v-html="PopupAddToCartVueModal.AttributeDescription">
</div>
</div>
- }
- @if (!string.IsNullOrEmpty(Model.ReservationInfo))
- {
+ </template>
+ <template v-if="PopupAddToCartVueModal.ReservationInfo !== null">
<div class="form-group col-12 px-0 d-none d-md-block">
<label class="w-100"><strong>@Loc["AddToCart.ReservationInfo"]</strong></label>
- <div class="attributes p-2">
- @Html.Raw(Model.ReservationInfo)
+ <div class="attributes p-2" v-html="PopupAddToCartVueModal.ReservationInfo">
</div>
</div>
- }
- @if (!Model.IsAuction)
- {
+ </template>
+ <template v-if="!PopupAddToCartVueModal.IsAuction">
<div class="form-group col-12 pl-0 mb-0 d-flex">
<label class="mb-0"><strong>@Loc["AddToCart.Qty"]</strong></label>
- <label class="pl-3 mb-0">@Model.Quantity</label>
+ <label class="pl-3 mb-0">{{PopupAddToCartVueModal.Quantity}}</label>
</div>
- }
- else
- {
+ </template>
+ <template v-else>
<div class="form-group col-12 pl-0 mb-0 d-flex">
- @if (Model.EndTime.HasValue)
- {
+ <template v-if="PopupAddToCartVueModal.EndTime !== null">
<div>
- @if (Model.EndTime > DateTime.UtcNow)
- {
- <countdown :end-time="@Model.EndTime.Value.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds">
+ <template v-if="new Date(PopupAddToCartVueModal.EndTime).getTime() > new Date().getTime()">
+ <countdown :end-time="new Date(PopupAddToCartVueModal.EndTime).getTime()">
<template v-slot:process="{ timeObj }">
<span class="col-form-label">@Loc["AddToCart.Timeleft"]:</span>
<span>{{ `${timeObj.d}` }} </span>
@@ -86,49 +60,53 @@
<span>@Loc["ShoppingCart.Auctionends"]</span>
</template>
</countdown>
- }
- else
- {
- <label>@Loc["ShoppingCart.Auctionends"]: @Model.EndTime.Value.ToString()</label>
- }
+ </template>
+ <template v-else>
+ <label>@Loc["ShoppingCart.Auctionends"]: {{PopupAddToCartVueModal.EndTime.Value}}</label>
+ </template>
</div>
- }
+ </template>
</div>
- }
+ </template>
+
<div class="form-group col-12 pl-0 mb-1 d-flex">
- @if (Model.IsAuction)
- {
+ <template v-if="PopupAddToCartVueModal.IsAuction">
<label class=""><strong>@Loc["AddToCart.Yourbid"]:</strong></label>
- <label class="pl-3 mb-0">@Model.HighestBid</label>
- }
- else
- {
+ <label class="pl-3 mb-0">{{PopupAddToCartVueModal.HighestBid}}</label>
+ </template>
+ <template v-else>
<label class=""><strong>@Loc["AddToCart.Price"]</strong></label>
- <label class="pl-3 mb-0">@Model.Price</label>
- }
+ <label class="pl-3 mb-0">{{PopupAddToCartVueModal.Price}}</label>
+ </template>
</div>
</div>
<div class="col-12">
<div class="jumbotron border mt-3 mb-0 p-3 text-center">
<h5>
- @text
+ <template v-if="PopupAddToCartVueModal.CartType == 1">
+ @Loc["AddToCart.Cart.Items"].ToString().Replace("{0}", "{{PopupAddToCartVueModal.TotalItems}}")
+ </template>
+ <template v-else-if="PopupAddToCartVueModal.CartType == 2">
+ @Loc["AddToCart.Wishlist.Items"].ToString().Replace("{0}", "{{PopupAddToCartVueModal.TotalItems}}")
+ </template>
+ <template v-else-if="PopupAddToCartVueModal.CartType == 3">
+ @Loc["AddToCart.Auctions.Ongoing"].ToString().Replace("{0}", "{{PopupAddToCartVueModal.TotalItems}}")
+ </template>
</h5>
<div class="lead">
- @if (!string.IsNullOrEmpty(Model.SubTotalDiscount))
- {
+ <template v-if="PopupAddToCartVueModal.SubTotalDiscount !== null">
<div class="form-group mb-1 d-flex justify-content-center">
<label class="text-muted mb-0">@Loc["AddToCart.SubTotalDiscount"]</label>
- <label class="pl-3 mb-0 text-muted">@Model.SubTotalDiscount</label>
+ <label class="pl-3 mb-0 text-muted">{{PopupAddToCartVueModal.SubTotalDiscount}}</label>
</div>
- }
- @if (!string.IsNullOrEmpty(Model.SubTotal))
- {
+ </template>
+ <template v-if="PopupAddToCartVueModal.SubTotal !== null">
<div class="form-group mb-0 d-flex justify-content-center">
<label class="text-dark mb-0">@Loc["AddToCart.SubTotal"]</label>
- <label class="pl-3 mb-0 text-dark mb-0">@Model.SubTotal</label>
+ <label class="pl-3 mb-0 text-dark mb-0">{{PopupAddToCartVueModal.SubTotal}}</label>
</div>
- }
+ </template>
</div>
</div>
</div>
@@ -137,30 +115,23 @@
</div>
<div class="card-footer">
<div class="btn-group w-100" role="group">
- @if (Model.CartType == ShoppingCartType.Auctions)
- {
+ <template v-if="PopupAddToCartVueModal.CartType == 3">
<button class="btn btn-outline-info text-uppercase" @@click='$bvModal.hide("ModalAddToCart")'>@Loc["AddToCart.Continue"]</button>
- }
- else
- {
+ </template>
+ <template v-else>
<button class="btn btn-outline-info text-uppercase" @@click='$bvModal.hide("ModalAddToCart")'>@Loc["AddToCart.Continue"]</button>
- }
- @if (Model.CartType == ShoppingCartType.ShoppingCart || Model.CartType == ShoppingCartType.OnHoldCart)
- {
+ </template>
+ <template v-if="PopupAddToCartVueModal.CartType == 1 || PopupAddToCartVueModal.CartType == 0">
<button class="btn btn-info text-uppercase" @@click="location='@(Url.RouteUrl("ShoppingCart"))'">@Loc["AddToCart.ViewCart"]</button>
- }
- else if (Model.CartType == ShoppingCartType.Wishlist)
- {
+ </template>
+ <template v-else-if="PopupAddToCartVueModal.CartType == 2">
<button class="btn btn-info text-uppercase" @@click="location='@(Url.RouteUrl("Wishlist"))'">@Loc["AddToCart.ViewWishlist"]</button>
- }
- else if (Model.CartType == ShoppingCartType.Auctions)
- {
+ </template>
+ <template v-else-if="PopupAddToCartVueModal.CartType == 3">
<button class="btn btn-info text-uppercase" @@click="location='@(Url.RouteUrl("CustomerAuctions"))'">@Loc["AddToCart.ViewAuctions"]</button>
- }
+ </template>
</div>
</div>
</div>
- </b-modal>
- <div class="script-tag">
- @await Component.InvokeAsync("Widget", new { widgetZone = "popup_add_to_cart_content_before", additionalData = Model })
- </div>
\ No newline at end of file
+ </template>
+</b-modal>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index 377a74e67..7b4c29a01 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -15,6 +15,7 @@
searchblog: null,
searchproducts: null,
flycartfirstload: true,
+ PopupAddToCartVueModal: null,
}
},
props: {
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 96dd29aee..a0869923e 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
@@ -148,7 +148,8 @@ var AxiosCart = {
if (response.data.message) {
if (response.data.success == true) {
//success
- displayPopupAddToCart(response.data.html);
+ vm.PopupAddToCartVueModal = response.data.model;
+ vm.$refs['ModalAddToCart'].show();
if (response.data.refreshreservation == true) {
var param = "";
if ($("#parameterDropdown").val() != null) {