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.

product review overview - updated on submit review

DanielŻuławski5a8ce61d2d7c
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 6a2b5cb9c..bff01eb64 100644
--- a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Default.cshtml
@@ -77,6 +77,7 @@
data: function () {
return {
Model: null,
+ rating: null,
captcha: null
}
},
diff --git a/src/Web/Grand.Web/Views/Product/_ProductReviewOverview.cshtml b/src/Web/Grand.Web/Views/Product/_ProductReviewOverview.cshtml
index 8cb38ee15..77aafd044 100644
--- a/src/Web/Grand.Web/Views/Product/_ProductReviewOverview.cshtml
+++ b/src/Web/Grand.Web/Views/Product/_ProductReviewOverview.cshtml
@@ -10,32 +10,23 @@
<div class="product-reviews-overview d-inline-flex align-items-center flex-wrap" @if (Model.TotalReviews > 0)
{ <text> itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" </text> }>
<div class="product-review-box d-inline-block order-1">
- @{
- double ratingValue = 0;
- if (Model.TotalReviews != 0)
- {
- ratingValue = Convert.ToDouble(((Model.RatingSum * (double)100) / Model.TotalReviews) / (double)100);
- }
- }
<div class="rating">
- <b-form-rating id="[email protected]" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline value="@(ratingValue.ToString("0.00", CultureInfo.InvariantCulture))"></b-form-rating>
- @if (Model.TotalReviews > 0)
- {
+ <b-form-rating id="[email protected]" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline v-model="productreviewsoverview.rating"></b-form-rating>
+ <template v-if="productreviewsoverview.Model.TotalReviews > 0">
<div class="product-review-links order-3">
<b-button variant="outline-info" size="sm" class="review-scroll-button" @@click="active = true" href="#review-tab___BV_tab_button__">
- @Model.TotalReviews
+ {{productreviewsoverview.Model.TotalReviews}}
@Loc["Reviews.Overview.Reviews"]
</b-button>
</div>
- }
- else
- {
+ </template>
+ <template v-else>
<div class="product-no-reviews order-3">
<a class="btn btn-sm btn-outline-info" @@click="addProductReview('@Url.RouteUrl("ProductReviews", new { productId = Model.ProductId })')">
@Loc["Reviews.Overview.First"]
</a>
</div>
- }
+ </template>
@{
@* rendering microdata info*@
double value = ratingPercent / (double)20;
@@ -45,3 +36,23 @@
</div>
</div>
</div>
+<script asp-location="Footer" asp-order="300">
+ var productreviewsoverview = new Vue({
+ data: function () {
+ return {
+ Model: null,
+ rating: 0
+ }
+ },
+ created() {
+ this.Model = @Json.Serialize(Model);
+ },
+ watch: {
+ Model: function() {
+ const RatingSum = this.Model.RatingSum;
+ const TotalReviews = this.Model.TotalReviews;
+ this.rating = RatingSum / TotalReviews;
+ }
+ }
+ })
+</script>
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index f2ee91d8f..6978f161f 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -416,6 +416,10 @@
this.toast();
}
});
+
+ if (response.data.ProductReviewOverviewModel !== null) {
+ productreviewsoverview.Model = response.data.ProductReviewOverviewModel;
+ }
});
return
}