From a891b8894210c4e88ca1bb3c8136bc53985974ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=C5=BBu=C5=82awski?= Date: Tue, 28 Sep 2021 13:18:56 +0200 Subject: [PATCH 1/8] Product Review Modal added --- .../Components/ProductReviews/Default.cshtml | 2 +- .../Views/Shared/_Notifications.cshtml | 1 + .../Shared/_ProductReview.VueModal.cshtml | 99 +++++++++++++++++++ src/Web/Grand.Web/wwwroot/theme/script/app.js | 37 +++++++ 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml diff --git a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml index 5f7e845b3..c82117c1f 100644 --- a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml +++ b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml @@ -1,7 +1,7 @@ @model ProductReviewsModel
- @Loc["Reviews.Overview.AddNew"] + @Loc["Reviews.Overview.AddNew"]
@if (Model.Items.Any()) diff --git a/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml b/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml index 56ddc48f9..5e7ad81e3 100644 --- a/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml +++ b/src/Web/Grand.Web/Views/Shared/_Notifications.cshtml @@ -40,4 +40,5 @@ + @await Component.InvokeAsync("PopupAction") diff --git a/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml b/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml new file mode 100644 index 000000000..8a6c6e797 --- /dev/null +++ b/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml @@ -0,0 +1,99 @@ +@{ + var productlink = @Url.RouteUrl("Product"); + var formaction = @Url.RouteUrl("ProductReviews"); +} + + + + \ 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 1e0b5fd85..4e52b028a 100644 --- a/src/Web/Grand.Web/wwwroot/theme/script/app.js +++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js @@ -17,6 +17,7 @@ flycartfirstload: true, PopupAddToCartVueModal: null, PopupQuickViewVueModal: null, + PopupProductReviewVueModal: null, index: null, RelatedProducts: null, } @@ -348,6 +349,42 @@ } } } + }, + addProductReview: function (url) { + axios({ + url: url, + method: 'get', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Response-View': 'Json' + } + }).then(function (response) { + vm.PopupProductReviewVueModal = response.data; + vm.$refs['ModalProductReview'].show(); + }); + }, + submitProductReview: function (id) { + this.$validator.validate('AddProductReview.*').then((result) => { + if (result) { + var form = document.getElementById(id); + var url = form.getAttribute("action"); + var bodyFormData = new FormData(form); + axios({ + method: "post", + url: url, + data: bodyFormData, + headers: { + "Content-Type": "multipart/form-data", + 'X-Response-View': 'Json' + }, + }).then(function (response) { + console.log(response); + vm.PopupProductReviewVueModal = response.data; + }); + return + } + }); } }, }); From 5d2a9dccbee4be56a406ba46908b351e35a44114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=C5=BBu=C5=82awski?= Date: Tue, 28 Sep 2021 16:06:50 +0200 Subject: [PATCH 2/8] ProductReview Modal - validate --- .../Views/Shared/_ProductReview.VueModal.cshtml | 16 ++++++++++++---- src/Web/Grand.Web/wwwroot/theme/script/app.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml b/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml index 8a6c6e797..67d8e50e8 100644 --- a/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml +++ b/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml @@ -1,6 +1,5 @@ @{ var productlink = @Url.RouteUrl("Product"); - var formaction = @Url.RouteUrl("ProductReviews"); } @@ -87,9 +86,18 @@ - @**@ + diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js index 4e52b028a..67df6ab99 100644 --- a/src/Web/Grand.Web/wwwroot/theme/script/app.js +++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js @@ -365,7 +365,7 @@ }); }, submitProductReview: function (id) { - this.$validator.validate('AddProductReview.*').then((result) => { + this.$validator.validateAll(['AddProductReview.Title', 'AddProductReview.ReviewText', 'AddProductReview_Rating']).then((result) => { if (result) { var form = document.getElementById(id); var url = form.getAttribute("action"); From c5cbd79946e6483ccb3f49fccb36dd83aa9e8171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=C5=BBu=C5=82awski?= Date: Wed, 29 Sep 2021 12:59:56 +0200 Subject: [PATCH 3/8] ProductReview modal --- .../Components/ProductReviews/Default.cshtml | 141 ++++++++++++------ .../Shared/_ProductReview.VueModal.cshtml | 71 +-------- src/Web/Grand.Web/wwwroot/theme/script/app.js | 31 +++- 3 files changed, 131 insertions(+), 112 deletions(-) diff --git a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml index c82117c1f..605dc20aa 100644 --- a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml +++ b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml @@ -4,57 +4,110 @@ @Loc["Reviews.Overview.AddNew"] -@if (Model.Items.Any()) -{ -
+ + + + \ No newline at end of file diff --git a/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml b/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml index 67d8e50e8..3d4252d87 100644 --- a/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml +++ b/src/Web/Grand.Web/Views/Shared/_ProductReview.VueModal.cshtml @@ -5,26 +5,21 @@