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.

ProductEmailAFriend - popup

DanielŻuławski1b02133931b2
diff --git a/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml b/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml
new file mode 100644
index 000000000..829621f1c
--- /dev/null
+++ b/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml
@@ -0,0 +1,147 @@
+@model ProductEmailAFriendModel
+
+<b-modal id="ModalProductEmailAFriend" ref="ModalProductEmailAFriend" :dark-theme="darkMode" size="xl" @if (Model.DisplayCaptcha) { <text> @@shown="emailafriend.modalEmailAFriendShown()" @@hide="emailafriend.modalEmailAFriendClose()" </text> } centered hide-footer hide-header>
+ <a class="modal-close" @@click="$bvModal.hide('ModalProductEmailAFriend')"><b-icon icon="x"></b-icon></a>
+ <h1 class="h2 text-xs-center generalTitle">@Loc["Products.EmailAFriend.Title"]</h1>
+ <div class="card">
+ <div class="card-header">
+ <h4 class="mb-0"><a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })" class="product">@Model.ProductName</a></h4>
+ </div>
+ <div class="card-body">
+ @if (Model.SuccessfullySent)
+ {
+ <div class="alert alert-info my-3 text-center result">
+ @Model.Result
+ </div>
+ }
+ else
+ {
+ <template v-if="emailafriend.Message.Result !== null && emailafriend.Message.SuccessfullySent">
+ <div class="alert alert-success">
+ {{emailafriend.Message.Result}}
+ </div>
+ </template>
+ <template v-else>
+ <validation-observer v-slot="{ handleSubmit }">
+ <form asp-route="ProductEmailAFriend" id="ProductEmailAFriend" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit($event))">
+ <div asp-validation-summary="ModelOnly" class="message-error"></div>
+ <div class="form-fields">
+ <div class="form-group">
+ <validation-provider tag="div" rules="required|email" name="FriendEmail" v-slot="{ errors, classes }">
+ <label asp-for="FriendEmail" class="col-form-label">@Loc["Products.EmailAFriend.FriendEmail"]:</label>
+ <input asp-for="FriendEmail" v-model="emailafriend.FriendEmail" placeholder="@Loc["Products.EmailAFriend.FriendEmail.Hint"]" v-bind:class="[classes , 'form-control friend-email']" autofocus="autofocus" />
+ <span class="field-validation-error">{{ errors[0] }}</span>
+ <span asp-validation-for="FriendEmail"></span>
+ </validation-provider>
+ </div>
+ <div class="form-group">
+ <validation-provider tag="div" rules="required|email" name="YourEmailAddress" v-slot="{ errors, classes }">
+ <label asp-for="YourEmailAddress" class="col-form-label">@Loc["Products.EmailAFriend.YourEmailAddress"]:</label>
+ <input asp-for="YourEmailAddress" v-model="emailafriend.YourEmailAddress" placeholder="@Loc["Products.EmailAFriend.YourEmailAddress.Hint"]" v-bind:class="[classes , 'form-control your-email']" autofocus="autofocus" />
+ <span class="field-validation-error">{{ errors[0] }}</span>
+ <span asp-validation-for="YourEmailAddress"></span>
+ </validation-provider>
+ </div>
+ <div class="form-group">
+ <validation-provider tag="div" rules="required" name="PersonalMessage" v-slot="{ errors, classes }">
+ <label asp-for="PersonalMessage" class="col-form-label">@Loc["Products.EmailAFriend.PersonalMessage"]:</label>
+ <textarea asp-for="PersonalMessage" v-model="emailafriend.PersonalMessage" placeholder="@Loc["Products.EmailAFriend.PersonalMessage.Hint"]" v-bind:class="[classes , 'form-control your-email']" autofocus="autofocus" rows="4"></textarea>
+ <span class="field-validation-error">{{ errors[0] }}</span>
+ <span asp-validation-for="YourEmailAddress"></span>
+ </validation-provider>
+ </div>
+ @if (Model.DisplayCaptcha)
+ {
+ <div id="captcha-popup" class="mb-3"></div>
+ }
+ </div>
+ <div class="btn-group">
+ <input type="submit" name="send-email" class="btn btn-info send-email-a-friend-button" data-form="emailafriend.submitEmailAFriend('@Url.RouteUrl("ProductEmailAFriend", new { productId = Model.ProductId })')" value="@Loc["Products.EmailAFriend.Button"]" />
+ </div>
+ </form>
+ </validation-observer>
+ </template>
+ <script asp-location="Footer" asp-order="300">
+ var emailafriend = new Vue({
+ data: () => ({
+ @{
+ <text>
+ FriendEmail: '@Html.Raw(Model.FriendEmail)',
+ YourEmailAddress: '@Html.Raw(Model.YourEmailAddress)',
+ PersonalMessage: '@Html.Raw(Model.PersonalMessage)',
+ Message: {
+ Result: null,
+ SuccessfullySent: false
+ }
+ </text>
+ }
+ }),
+ methods: {
+ @{
+ if (Model.DisplayCaptcha) {
+ <text>
+ modalEmailAFriendShown: function () {
+ if (document.querySelector("#ModalProductEmailAFriend .captcha-box") == null && !emailafriend.Message.SuccessfullyAdded) {
+ var html = document.getElementById("captcha-box");
+ document.getElementById("captcha-popup").prepend(html);
+ }
+ },
+ modalEmailAFriendClose: function () {
+ if (document.querySelector("#ModalProductEmailAFriend .captcha-box") !== null) {
+ var html = document.getElementById("captcha-box");
+ document.getElementById("captcha-container").prepend(html);
+ }
+ },
+ </text>
+ }
+ }
+ submitEmailAFriend(url) {
+ var bodyFormData = new FormData(document.getElementById("ProductEmailAFriend"));
+ axios({
+ url: url,
+ data: bodyFormData,
+ method: 'post',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-Response-View': 'Json'
+ }
+ }).then(function (response) {
+ emailafriend.Message.Result = response.data.Result;
+ emailafriend.Message.SuccessfullySent = response.data.SuccessfullySent;
+
+ var result = response.data.Result;
+ var variant = "";
+
+ if (response.data.SuccessfullySent) {
+ variant = "info";
+ document.getElementById("ProductEmailAFriend").style.display = "none";
+ vm.$refs['ModalProductEmailAFriend'].hide();
+ } else {
+ variant = "danger";
+ }
+
+ new Vue({
+ el: ".modal-place",
+ methods: {
+ toast() {
+ this.$bvToast.toast(result, {
+ variant: variant,
+ autoHideDelay: 3000,
+ solid: true
+ })
+ }
+ },
+ mounted: function () {
+ this.toast();
+ }
+ });
+ })
+ }
+ }
+ });
+ </script>
+ }
+ </div>
+ </div>
+</b-modal>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/ProductEmailAFriend.cshtml b/src/Web/Grand.Web/Views/Product/ProductEmailAFriend.cshtml
deleted file mode 100644
index 26ba5705f..000000000
--- a/src/Web/Grand.Web/Views/Product/ProductEmailAFriend.cshtml
+++ /dev/null
@@ -1,81 +0,0 @@
-@model ProductEmailAFriendModel
-@inject IPageHeadBuilder pagebuilder
-@{
- Layout = "_SingleColumn";
-
- //title
- pagebuilder.AddTitleParts(Model.ProductName);
- pagebuilder.AddTitleParts(Loc["Title.ProductEmailAFriend"]);
-}
-<div class="page email-a-friend-page">
- <h1 class="h2 text-xs-center generalTitle">@Loc["Products.EmailAFriend.Title"]</h1>
- <div class="card">
- <div class="card-header">
- <h4 class="mb-0"><a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })" class="product">@Model.ProductName</a></h4>
- </div>
- <div class="card-body">
- @if (Model.SuccessfullySent)
- {
- <div class="alert alert-info my-3 text-center result">
- @Model.Result
- </div>
- }
- else
- {
- <validation-observer v-slot="{ handleSubmit }">
- <form asp-route="ProductEmailAFriend" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">
- <div asp-validation-summary="ModelOnly" class="message-error"></div>
- <div class="form-fields">
- <div class="form-group">
- <validation-provider tag="div" rules="required|email" name="FriendEmail" v-slot="{ errors, classes }">
- <label asp-for="FriendEmail" class="col-form-label">@Loc["Products.EmailAFriend.FriendEmail"]:</label>
- <input asp-for="FriendEmail" v-model="emailafriend.FriendEmail" placeholder="@Loc["Products.EmailAFriend.FriendEmail.Hint"]" v-bind:class="[classes , 'form-control friend-email']" autofocus="autofocus" />
- <span class="field-validation-error">{{ errors[0] }}</span>
- <span asp-validation-for="FriendEmail"></span>
- </validation-provider>
- </div>
- <div class="form-group">
- <validation-provider tag="div" rules="required|email" name="YourEmailAddress" v-slot="{ errors, classes }">
- <label asp-for="YourEmailAddress" class="col-form-label">@Loc["Products.EmailAFriend.YourEmailAddress"]:</label>
- <input asp-for="YourEmailAddress" v-model="emailafriend.YourEmailAddress" placeholder="@Loc["Products.EmailAFriend.YourEmailAddress.Hint"]" v-bind:class="[classes , 'form-control your-email']" autofocus="autofocus" />
- <span class="field-validation-error">{{ errors[0] }}</span>
- <span asp-validation-for="YourEmailAddress"></span>
- </validation-provider>
- </div>
- <div class="form-group">
- <validation-provider tag="div" rules="required" name="PersonalMessage" v-slot="{ errors, classes }">
- <label asp-for="PersonalMessage" class="col-form-label">@Loc["Products.EmailAFriend.PersonalMessage"]:</label>
- <textarea asp-for="PersonalMessage" v-model="emailafriend.PersonalMessage" placeholder="@Loc["Products.EmailAFriend.PersonalMessage.Hint"]" v-bind:class="[classes , 'form-control your-email']" autofocus="autofocus" rows="4"></textarea>
- <span class="field-validation-error">{{ errors[0] }}</span>
- <span asp-validation-for="YourEmailAddress"></span>
- </validation-provider>
- </div>
- @if (Model.DisplayCaptcha)
- {
- <div class="captcha-box">
- <captcha />
- </div>
- }
- </div>
- <div class="btn-group">
- <input type="submit" name="send-email" class="btn btn-info send-email-a-friend-button" value="@Loc["Products.EmailAFriend.Button"]" />
- </div>
- </form>
- </validation-observer>
- <script asp-location="Footer" asp-order="300">
- var emailafriend = new Vue({
- data: () => ({
- @{
- <text>
- FriendEmail: '@Html.Raw(Model.FriendEmail)',
- YourEmailAddress: '@Html.Raw(Model.YourEmailAddress)',
- PersonalMessage: '@Html.Raw(Model.PersonalMessage)',
- </text>
- }
- })
- });
- </script>
- }
- </div>
- </div>
-</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
index 2cdebfa49..d460e077a 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
@@ -150,7 +150,7 @@
<di class="card overflow-hidden associatedItem mb-3">
<div class="row no-gutters">
<div class="col-lg-3 col-md-4">
- <img class="img-fluid" id="[email protected]" alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl" class="rounded-0"/>
+ <img class="img-fluid" id="[email protected]" alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl" class="rounded-0" />
</div>
<div class="col-lg-9 col-md-8">
<div class="card-body overview" title="@variant.Name">
@@ -163,7 +163,7 @@
<partial name="_Codes" model="variant" />
<!--delivery-->
@if ((variant.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(variant.DeliveryDate)
- || variant.NotReturnable || variant.AdditionalShippingCharge > 0)
+ || variant.NotReturnable || variant.AdditionalShippingCharge > 0)
{
<partial name="_DeliveryInfo" model="variant" />
}
@@ -227,9 +227,17 @@
}
</div>
</div>
+ @if (Model.RenderCaptcha)
+ {
+ <partial name="_Captcha" />
+ }
</div>
@await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })
</form>
</validation-observer>
+ @if (Model.EmailAFriendEnabled)
+ {
+ @await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })
+ }
@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_bottom", additionalData = Model.Id })
</div>
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
index a38d75f88..677db59a4 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
@@ -97,7 +97,7 @@
<partial name="_Codes" model="Model" />
<!--delivery-->
@if ((Model.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(Model.DeliveryDate)
- || Model.NotReturnable || Model.AdditionalShippingCharge > 0)
+ || Model.NotReturnable || Model.AdditionalShippingCharge > 0)
{
<partial name="_DeliveryInfo" model="Model" />
}
@@ -240,8 +240,12 @@
{
<partial name="_Captcha" />
}
- </div>
+ </div>
</form>
</validation-observer>
+ @if (Model.EmailAFriendEnabled)
+ {
+ @await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })
+ }
<vc:widget widget-zone="productdetails_bottom" additional-data="@Model.Id"></vc:widget>
</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/_SendFriend.cshtml b/src/Web/Grand.Web/Views/Product/_SendFriend.cshtml
index cc9cce5eb..81d5395be 100644
--- a/src/Web/Grand.Web/Views/Product/_SendFriend.cshtml
+++ b/src/Web/Grand.Web/Views/Product/_SendFriend.cshtml
@@ -1,5 +1,5 @@
@model ProductDetailsModel
-<a class="btn btn-secondary email-a-friend-button mr-1" href="@Url.RouteUrl("ProductEmailAFriend", new { productId = Model.Id })" v-b-tooltip.hover.bottom title="@Loc["Products.EmailAFriend"]">
+<a class="btn btn-secondary email-a-friend-button mr-1" @@click="$bvModal.show('ModalProductEmailAFriend')" v-b-tooltip.hover.bottom title="@Loc["Products.EmailAFriend"]">
<b-icon icon="envelope"></b-icon>
<span class="sr-only">@Loc["Products.EmailAFriend"]</span>
-</a>
+</a>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Shared/QuickView/_SendFriend.cshtml b/src/Web/Grand.Web/Views/Shared/QuickView/_SendFriend.cshtml
deleted file mode 100644
index fa8b41333..000000000
--- a/src/Web/Grand.Web/Views/Shared/QuickView/_SendFriend.cshtml
+++ /dev/null
@@ -1,9 +0,0 @@
-@{
- var sendfriend = @Url.RouteUrl("ProductEmailAFriend");
-}
-<template v-if="PopupQuickViewVueModal.EmailAFriendEnabled">
- <a class="btn btn-secondary email-a-friend-button mr-1" :href="'@sendfriend/' + PopupQuickViewVueModal.Id" v-b-tooltip.hover.bottom title="@Loc["Products.EmailAFriend"]">
- <b-icon icon="envelope"></b-icon>
- <span class="sr-only">@Loc["Products.EmailAFriend"]</span>
- </a>
-</template>
diff --git a/src/Web/Grand.Web/Views/Shared/_ProductQuickView.cshtml b/src/Web/Grand.Web/Views/Shared/_ProductQuickView.cshtml
index 90e1377f7..b7075a6cc 100644
--- a/src/Web/Grand.Web/Views/Shared/_ProductQuickView.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_ProductQuickView.cshtml
@@ -97,7 +97,6 @@
<div class="btn-group mt-2 mb-3 w-100">
<partial name="QuickView/_AddToWishlist" />
<partial name="QuickView/_ProductsComparison" />
- <partial name="QuickView/_SendFriend" />
</div>
</template>
</template>