diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml index 1b3f3ff94c..860c2350ac 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml @@ -48,7 +48,12 @@ @if (GlobalFeatureManager.Instance.IsEnabled()) { - @await Component.InvokeAsync(typeof(RatingViewComponent), new {entityType = "quote", entityId = "1"}) + @await Component.InvokeAsync(typeof(RatingViewComponent), new + { + entityType = "quote", + entityId = "1", + isReadOnly = false + }) } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/Default.cshtml index 9b7f6e24f7..95879128a7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/Default.cshtml @@ -6,58 +6,59 @@ @inject IHtmlLocalizer L
-
-
- @if (CurrentUser.IsAuthenticated) +
+
+ + @if (CurrentUser.IsAuthenticated) + { + @if (!Model.IsReadOnly && Model.CurrentRating != null) { - @if (Model.CurrentRating != null) - { - - @L["Undo"] - - } - if (Model.Ratings != null) - { - - - + + @L["Undo"] + + } + if (Model.Ratings != null) + { + + + - "> + + }
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs index b928f7e2af..7ab1df47b8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs @@ -31,7 +31,7 @@ public class RatingViewComponent : AbpViewComponent CurrentUser = currentUser; } - public virtual async Task InvokeAsync(string entityType, string entityId) + public virtual async Task InvokeAsync(string entityType, string entityId, bool isReadOnly = false) { var ratings = await RatingPublicAppService.GetGroupedStarCountsAsync(entityType, entityId); var totalRating = ratings.Sum(x => x.Count); @@ -52,7 +52,8 @@ public class RatingViewComponent : AbpViewComponent LoginUrl = loginUrl, Ratings = ratings, CurrentRating = currentUserRating, - TotalRating = totalRating + TotalRating = totalRating, + IsReadOnly = isReadOnly }; return View("~/Pages/CmsKit/Shared/Components/Rating/Default.cshtml", viewModel); @@ -72,4 +73,6 @@ public class RatingViewModel public short? CurrentRating { get; set; } public int TotalRating { get; set; } + + public bool IsReadOnly { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/default.js b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/default.js index 22531b47f3..69bb1bac4f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/default.js +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/default.js @@ -15,6 +15,7 @@ function registerCreateOfNewRating() { $widget.find(".my-rating").each(function () { var authenticated = $(this).attr("data-authenticated"); + var readonly = $(this).attr("data-readonly"); $(this).starRating({ initialRating: 0, @@ -26,7 +27,7 @@ strokeWidth: 0, disableAfterRate: true, useFullStars: true, - readOnly: authenticated === "True", + readOnly: authenticated === "True" || readonly === "True", onHover: function (currentIndex, currentRating, $el) { $widget.find(".live-rating").text(currentIndex); },