diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml index 62b000a784..1846666943 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml @@ -3,6 +3,7 @@ @using Microsoft.Extensions.Localization @using Volo.CmsKit.Pages @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting +@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection @model PublicModel @inject IStringLocalizer Localizer

CMS Kit DEMO - Public

@@ -18,7 +19,9 @@ - @await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "publicQuote", entityId = "1", loginUrl="Account/Login?ReturnUrl=%2Fpublic" }) + @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new { entityType = "publicQuote", entityId = "1" }) +
+ @await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "publicQuote", entityId = "1", loginUrl = "Account/Login?ReturnUrl=%2Fpublic" }) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs index b70300f180..6a1431f065 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; using Volo.Abp.Users; using Volo.CmsKit.Reactions; @@ -30,12 +31,13 @@ namespace Volo.CmsKit.Public.Reactions { var summaries = await ReactionManager.GetSummariesAsync(entityType, entityId); - var userReactions = (await UserReactionRepository + var userReactions = CurrentUser.IsAuthenticated ? + (await UserReactionRepository .GetListForUserAsync( CurrentUser.GetId(), entityType, entityId - )).ToDictionary(x => x.ReactionName, x => x); + )).ToDictionary(x => x.ReactionName, x => x) : null; var reactionWithSelectionDtos = new List(); @@ -46,7 +48,7 @@ namespace Volo.CmsKit.Public.Reactions { Reaction = ConvertToReactionDto(summary.Reaction), Count = summary.Count, - IsSelectedByCurrentUser = userReactions.ContainsKey(summary.Reaction.Name) + IsSelectedByCurrentUser = userReactions?.ContainsKey(summary.Reaction.Name) ?? false } ); } @@ -54,6 +56,7 @@ namespace Volo.CmsKit.Public.Reactions return new ListResultDto(reactionWithSelectionDtos); } + [Authorize] public virtual async Task CreateAsync(CreateReactionDto input) { await ReactionManager.CreateAsync( @@ -64,6 +67,7 @@ namespace Volo.CmsKit.Public.Reactions ); } + [Authorize] public virtual async Task DeleteAsync(DeleteReactionDto input) { await ReactionManager.DeleteAsync( diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/default.js b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/default.js index 29def70797..4fb29abb51 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/default.js +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/default.js @@ -87,7 +87,7 @@ abp.message.confirm(l("MessageDeletionConfirmationMessage"), function (ok) { if (ok){ - volo.cmsKit.comments.commentPublic.delete($link.data('id') + volo.cmsKit.public.comments.commentPublic.delete($link.data('id') ).then(function () { widgetManager.refresh($widget); }); @@ -103,7 +103,7 @@ $form.submit(function (e) { e.preventDefault(); var formAsObject = $form.serializeFormToObject(); - volo.cmsKit.comments.commentPublic.update( + volo.cmsKit.public.comments.commentPublic.update( formAsObject.id, { text: formAsObject.commentText @@ -121,8 +121,7 @@ $form.submit(function (e) { e.preventDefault(); var formAsObject = $form.serializeFormToObject(); - console.log(formAsObject); - volo.cmsKit.comments.commentPublic.create( + volo.cmsKit.public.comments.commentPublic.create( $.extend(getFilters(), { repliedCommentId: formAsObject.repliedCommentId, text: formAsObject.commentText diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml index a025ae6203..9096f8f154 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml @@ -1,17 +1,23 @@ -@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection.ReactionSelectionViewComponent.ReactionSelectionViewModel +@inject ICurrentUser CurrentUser +@using Volo.Abp.Users +@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection.ReactionSelectionViewComponent.ReactionSelectionViewModel - - + + @if (CurrentUser.IsAuthenticated) + { + + + } @foreach (var reaction in Model.Reactions.Where(r => r.Count > 0)) { - + @(reaction.Count) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/default.js b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/default.js index 7901557e72..38e5da93e5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/default.js +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/default.js @@ -26,11 +26,15 @@ function registerClickOfReactionIcons($container) { $container.find('.cms-reaction-icon').each(function () { var $icon = $(this); + var reactionName = $icon.attr('data-reaction-name'); + if ($icon.attr('data-click-action') === 'false'){ + return; + } $icon.click(function () { var methodName = $icon.hasClass('cms-reaction-icon-selected') ? 'delete' : 'create'; - volo.cmsKit.reactions.reactionPublic[methodName]( + volo.cmsKit.public.reactions.reactionPublic[methodName]( $.extend(getFilters(), { - reactionName: $icon.attr('data-reaction-name') + reactionName: reactionName }) ).then(function () { $selectIcon.popover('hide');