From 418eaae748f5bfc420f4ecffd5300b0184ec783d Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 10:58:12 +0800 Subject: [PATCH 1/9] Configure RefreshUrl for the widget --- .../Comments/CommentController.cs | 2 +- .../EasyAbp.EasyComment.HttpApi.csproj | 4 ---- .../CommentWidget/CommentWidgetController.cs | 15 ++++++++++++++ .../CommentWidgetViewComponent.cs | 6 ++++-- .../Components/CommentWidget/Default.cshtml | 14 +++++++++++-- .../Components/CommentWidget/Default.css | 20 ++++++++++--------- .../Components/CommentWidget/Default.js | 1 + .../Pages/Shared/_ViewImports.cshtml | 4 ++++ 8 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs rename src/EasyAbp.EasyComment.Web/Pages/{ => Shared}/Components/CommentWidget/CommentWidgetViewComponent.cs (73%) rename src/EasyAbp.EasyComment.Web/Pages/{ => Shared}/Components/CommentWidget/Default.cshtml (65%) rename src/EasyAbp.EasyComment.Web/Pages/{ => Shared}/Components/CommentWidget/Default.css (57%) create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/_ViewImports.cshtml diff --git a/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs b/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs index 936ef80..42121d5 100644 --- a/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs +++ b/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs @@ -8,7 +8,7 @@ namespace EasyAbp.EasyComment.Comments { [RemoteService(Name = "CommentService")] - [Route("/api/EasyComment/comment")] + [Route("/api/easyComment/comment")] public class CommentController : EasyCommentController, ICommentAppService { private readonly ICommentAppService _service; diff --git a/src/EasyAbp.EasyComment.HttpApi/EasyAbp.EasyComment.HttpApi.csproj b/src/EasyAbp.EasyComment.HttpApi/EasyAbp.EasyComment.HttpApi.csproj index 6807f35..925d3b0 100644 --- a/src/EasyAbp.EasyComment.HttpApi/EasyAbp.EasyComment.HttpApi.csproj +++ b/src/EasyAbp.EasyComment.HttpApi/EasyAbp.EasyComment.HttpApi.csproj @@ -12,8 +12,4 @@ - - - - diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs new file mode 100644 index 0000000..218aa01 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget +{ + [Route("/widgets/easyComment")] + public class CommentWidgetController : EasyCommentController + { + [HttpGet] + [Route("comments")] + public IActionResult Comments(string itemType, string itemKey) + { + return ViewComponent("CommentWidget", new {itemType, itemKey}); + } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/CommentWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs similarity index 73% rename from src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/CommentWidgetViewComponent.cs rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs index a98857b..8db5293 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/CommentWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs @@ -5,10 +5,12 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -namespace EasyAbp.EasyComment.Web.Pages.Components.CommentWidget +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget { [Widget( - StyleFiles = new[] {"/Pages/Components/CommentWidget/Default.css"} + RefreshUrl = "/widgets/easyComment/comments", + ScriptFiles = new[]{"/Pages/Shared/Components/CommentWidget/Default.js"}, + StyleFiles = new[] {"/Pages/Shared/Components/CommentWidget/Default.css"} )] public class CommentWidgetViewComponent : AbpViewComponent { diff --git a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml similarity index 65% rename from src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml index 5d343af..34a0d51 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml @@ -1,23 +1,33 @@ @using EasyAbp.EasyComment.Comments.Dtos @using EasyAbp.EasyComment.Localization @using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.Users @inject IHtmlLocalizer L +@inject ICurrentUser CurrentUser @L["TotalComments", Model.TotalCount] - @{ int i = 1;} + @{ int i = 1; } @foreach (CommentDto comment in Model.Items) { #@(i++)

@comment.CreatorName

- @comment.CreationTime +

@comment.Content


} + @if (CurrentUser.IsAuthenticated) + { + + + } + else + { + }
\ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css similarity index 57% rename from src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css index 3f1f9a8..7b7642d 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Components/CommentWidget/Default.css +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css @@ -2,26 +2,28 @@ margin: 10px; } -div.ec-comment { +.ec-comment { margin: 10px; } -div.ec-comment span { - margin-left: 5px; -} - -a.ec-comment-link { +.ec-comment-link { margin-right: 5px; } -p.ec-creator { +.ec-creator { font-weight: bold; } -p.ec-content { +.ec-content { line-break: anywhere; } -span.ec-comment-time { +.ec-comment-time { color: gray; + margin-left: 5px; +} + +.ec-new-comment { + margin-top: 20px; + width:100%; } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/_ViewImports.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/_ViewImports.cshtml new file mode 100644 index 0000000..c1da1f5 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/_ViewImports.cshtml @@ -0,0 +1,4 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling \ No newline at end of file From f14432b286c816c8f0392f005e4903b0a1a0192b Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 14:34:18 +0800 Subject: [PATCH 2/9] Implement adding comment --- EasyAbp.EasyComment.sln.DotSettings | 1 + .../Comments/ICommentAppService.cs | 3 +- .../Comments/CommentAppService.cs | 14 ++++++++- .../Localization/EasyComment/en.json | 8 +++-- .../Localization/EasyComment/zh-Hans.json | 8 +++-- .../Comments/CommentController.cs | 11 +++++-- .../CommentWidgetViewComponent.cs | 7 ++++- .../CommentWidget/CommentWidgetViewModel.cs | 25 +++++++++++++++ .../Components/CommentWidget/Default.cshtml | 14 ++++++--- .../Components/CommentWidget/Default.css | 6 +++- .../Components/CommentWidget/Default.js | 31 ++++++++++++++++++- .../TagHelpers/ECInputTagHelperService.cs | 25 +++++++++++++++ 12 files changed, 138 insertions(+), 15 deletions(-) create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs create mode 100644 src/EasyAbp.EasyComment.Web/TagHelpers/ECInputTagHelperService.cs diff --git a/EasyAbp.EasyComment.sln.DotSettings b/EasyAbp.EasyComment.sln.DotSettings index cb0b2c9..adf7c7c 100644 --- a/EasyAbp.EasyComment.sln.DotSettings +++ b/EasyAbp.EasyComment.sln.DotSettings @@ -19,5 +19,6 @@ True False False + EC SQL \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Application.Contracts/Comments/ICommentAppService.cs b/src/EasyAbp.EasyComment.Application.Contracts/Comments/ICommentAppService.cs index ec60833..acbc0c7 100644 --- a/src/EasyAbp.EasyComment.Application.Contracts/Comments/ICommentAppService.cs +++ b/src/EasyAbp.EasyComment.Application.Contracts/Comments/ICommentAppService.cs @@ -14,7 +14,8 @@ public interface ICommentAppService : CreateUpdateCommentDto, CreateUpdateCommentDto> { + Task AddCommentAsync(CreateUpdateCommentDto input); Task UpdateContentAsync(UpdateContentInput input); - Task DeleteCommentAsync(Guid id); + Task RemoveCommentAsync(Guid id); } } diff --git a/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs b/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs index c8b56b8..5fd1570 100644 --- a/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs +++ b/src/EasyAbp.EasyComment.Application/Comments/CommentAppService.cs @@ -55,6 +55,18 @@ protected override CommentDto MapToGetListOutputDto(Comment entity) return dto; } + [Authorize] + public virtual async Task AddCommentAsync(CreateUpdateCommentDto input) + { + var entity = MapToEntity(input); + + TryToSetTenantId(entity); + + await Repository.InsertAsync(entity, autoSave: true); + + return MapToGetOutputDto(entity); + } + [Authorize] public virtual async Task UpdateContentAsync(UpdateContentInput input) { @@ -69,7 +81,7 @@ public virtual async Task UpdateContentAsync(UpdateContentInput inpu } [Authorize] - public virtual async Task DeleteCommentAsync(Guid id) + public virtual async Task RemoveCommentAsync(Guid id) { var comment = await GetEntityByIdAsync(id); if (comment.CreatorId != CurrentUser.GetId()) diff --git a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json index 2c00842..5d11afb 100644 --- a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json +++ b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json @@ -11,7 +11,7 @@ "Comment": "Comment", "CommentItemType": "Item Type", "CommentItemKey": "Item Key", - "CommentContent": "Content", + "CommentContent": "Comment Content", "CommentReplyTo": "Reply To", "CreateComment": "Create Comment", "EditComment": "Edit Comment", @@ -19,6 +19,10 @@ "SuccessfullyDeleted": "Successfully deleted", "EasyComment:001" : "Users are only allowed to edit their own comments", "EasyComment:002" : "Users are only allowed to delete their own comments", - "TotalComments" : "{0} comments" + "TotalComments" : "{0} comments", + "SubmitComment": "Submit", + "LeaveComment": "Leave Comment", + "NeedCommentContent": "Please enter the content", + "SuccessfullyPublishComment": "Comment published successfully" } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json index 172e66f..e4753ed 100644 --- a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json +++ b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json @@ -12,7 +12,7 @@ "Comment": "评论", "CommentItemType": "项目类型", "CommentItemKey": "项目键值", - "CommentContent": "内容", + "CommentContent": "评论内容", "CommentReplyTo": "回复给", "CreateComment": "创建评论", "EditComment": "编辑评论", @@ -20,6 +20,10 @@ "SuccessfullyDeleted": "删除成功", "EasyComment:001" : "用户只能更新自己的评论", "EasyComment:002" : "用户只能删除自己的评论", - "TotalComments" : "共 {0} 条评论" + "TotalComments" : "共 {0} 条评论", + "SubmitComment": "提交评论", + "LeaveComment": "发表评论", + "NeedCommentContent": "请输入评论内容", + "SuccessfullyPublishComment": "发表评论成功" } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs b/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs index 42121d5..5dae620 100644 --- a/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs +++ b/src/EasyAbp.EasyComment.HttpApi/Comments/CommentController.cs @@ -51,6 +51,13 @@ public Task DeleteAsync(Guid id) return _service.DeleteAsync(id); } + [HttpPost] + [Route("comment")] + public Task AddCommentAsync(CreateUpdateCommentDto input) + { + return _service.AddCommentAsync(input); + } + [HttpPut] [Route("content")] public Task UpdateContentAsync(UpdateContentInput input) @@ -60,9 +67,9 @@ public Task UpdateContentAsync(UpdateContentInput input) [HttpDelete] [Route("{id}/comment")] - public Task DeleteCommentAsync(Guid id) + public Task RemoveCommentAsync(Guid id) { - return _service.DeleteCommentAsync(id); + return _service.RemoveCommentAsync(id); } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs index 8db5293..e22a09e 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs @@ -28,7 +28,12 @@ public async Task InvokeAsync(string itemType, string item ItemType = itemType, ItemKey = itemKey, }); - return View(comments); + return View(new CommentWidgetViewModel + { + ItemType = itemType, + ItemKey = itemKey, + Comments = comments, + }); } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs new file mode 100644 index 0000000..28e364a --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; +using EasyAbp.EasyComment.Comments.Dtos; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget +{ + public class CommentWidgetViewModel + { + [HiddenInput] + public string ItemType { get; set; } + + [HiddenInput] + public string ItemKey { get; set; } + + public PagedResultDto Comments { get; set; } + + [BindProperty] + [Required(ErrorMessage = "NeedCommentContent")] + [TextArea] + [Display(Name = "CommentContent")] + public string Content { get; set; } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml index 34a0d51..4d927e9 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml @@ -2,15 +2,18 @@ @using EasyAbp.EasyComment.Localization @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Abp.Users +@model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget.CommentWidgetViewModel @inject IHtmlLocalizer L @inject ICurrentUser CurrentUser + + - @L["TotalComments", Model.TotalCount] + @L["TotalComments", Model.Comments.TotalCount] @{ int i = 1; } - @foreach (CommentDto comment in Model.Items) + @foreach (CommentDto comment in Model.Comments.Items) { @@ -24,8 +27,11 @@ } @if (CurrentUser.IsAuthenticated) { - - +
+ + + + } else { diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css index 7b7642d..98dcacd 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css @@ -23,7 +23,11 @@ margin-left: 5px; } -.ec-new-comment { +.ec-leave-comment { margin-top: 20px; + font-size: medium; +} + +.ec-textarea-new-comment { width:100%; } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js index 5f28270..1b1ff40 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js @@ -1 +1,30 @@ - \ No newline at end of file +$(function() { + var l = abp.localization.getResource("EasyComment"); + + $(".ec-button-new-comment").click(function (e) { + e.preventDefault(); + + var form = e.currentTarget.closest("form"); + if (!$(form).valid()) return; + + var widgetWrapper = $(form).closest(".abp-widget-wrapper"); + var service = easyAbp.easyComment.comments.comment; + var itemType = $(widgetWrapper).find("#ItemType").val(); + var itemKey = $(widgetWrapper).find("#ItemKey").val(); + var content = $(widgetWrapper).find(".ec-textarea-new-comment").val(); + + service.addComment({ + itemType: itemType, + itemKey: itemKey, + content: content, + // TODO: replyTo: replyTo + }) + .then(function () { + abp.notify.info(l("SuccessfullyPublishComment")); + var widgetManager = new abp.WidgetManager($(widgetWrapper).parent()); + widgetManager.init(); + widgetManager.refresh(); + }); + }) +}) + diff --git a/src/EasyAbp.EasyComment.Web/TagHelpers/ECInputTagHelperService.cs b/src/EasyAbp.EasyComment.Web/TagHelpers/ECInputTagHelperService.cs new file mode 100644 index 0000000..23894a4 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/TagHelpers/ECInputTagHelperService.cs @@ -0,0 +1,25 @@ +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; +using Volo.Abp.DependencyInjection; + +namespace EasyAbp.EasyComment.Web.TagHelpers +{ + [ExposeServices(typeof(AbpInputTagHelperService))] + public class ECInputTagHelperService : AbpInputTagHelperService + { + public ECInputTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IAbpTagHelperLocalizer tagHelperLocalizer) : base(generator, encoder, tagHelperLocalizer) + { + } + + protected override async Task GetLabelAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag, bool isCheckbox) + { + if (context.AllAttributes.ContainsName("no-label")) return ""; + + return await base.GetLabelAsHtmlAsync(context, output, inputTag, isCheckbox); + } + } +} \ No newline at end of file From 4b5a71e5195c94a437d597e48557272f761e5a6b Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 15:40:21 +0800 Subject: [PATCH 3/9] Add dropdown menus --- .../Pages/Comments.cshtml | 14 ++++++---- .../Localization/EasyComment/en.json | 5 +++- .../Localization/EasyComment/zh-Hans.json | 5 +++- .../Components/CommentWidget/Default.cshtml | 28 +++++++++++++++++-- .../Components/CommentWidget/Default.css | 6 ++++ 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml b/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml index 4c103c8..cef09e4 100644 --- a/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml +++ b/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml @@ -1,11 +1,13 @@ @page @model EasyAbp.EasyComment.Pages.Comments -

Comments

-@await Component.InvokeAsync("CommentWidget", new -{ - ItemType = "TestItemType", - ItemKey = "TestItemKey" -}) +
+

Comments

+ @await Component.InvokeAsync("CommentWidget", new + { + ItemType = "TestItemType", + ItemKey = "TestItemKey" + }) +
diff --git a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json index 5d11afb..79ea1b2 100644 --- a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json +++ b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json @@ -23,6 +23,9 @@ "SubmitComment": "Submit", "LeaveComment": "Leave Comment", "NeedCommentContent": "Please enter the content", - "SuccessfullyPublishComment": "Comment published successfully" + "SuccessfullyPublishComment": "Comment published successfully", + "Remove": "Delete", + "Reference": "Reference", + "Reply": "Reply", } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json index e4753ed..1720bde 100644 --- a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json +++ b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json @@ -24,6 +24,9 @@ "SubmitComment": "提交评论", "LeaveComment": "发表评论", "NeedCommentContent": "请输入评论内容", - "SuccessfullyPublishComment": "发表评论成功" + "SuccessfullyPublishComment": "发表评论成功", + "Remove": "删除", + "Reference": "引用", + "Reply": "回复" } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml index 4d927e9..bc700fd 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml @@ -17,9 +17,31 @@ { - #@(i++) -

@comment.CreatorName

- + + + #@(i++) +

@comment.CreatorName

+ +
+
+ + + + + @if (comment.CreatorId == CurrentUser.GetId()) + { + @L["Edit"] + } + @L["Reply"] + @L["Reference"] + @if (comment.CreatorId == CurrentUser.GetId()) + { + + @L["Remove"] + } + + +

@comment.Content


diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css index 98dcacd..313a773 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css @@ -30,4 +30,10 @@ .ec-textarea-new-comment { width:100%; +} + +/*Remove the arrow of dropdowns */ +.dropdown-toggle::after { + border: none; + content: none; } \ No newline at end of file From 61bd7447581876fa072f10f8c2b0937f387c2ae7 Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 16:29:12 +0800 Subject: [PATCH 4/9] dropdown menu handler --- .../Localization/EasyComment/en.json | 2 +- .../Localization/EasyComment/zh-Hans.json | 2 +- .../Components/CommentWidget/Default.cshtml | 13 ++++----- .../Components/CommentWidget/Default.css | 6 +++++ .../Components/CommentWidget/Default.js | 27 ++++++++++++++----- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json index 79ea1b2..e267cbd 100644 --- a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json +++ b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/en.json @@ -20,7 +20,7 @@ "EasyComment:001" : "Users are only allowed to edit their own comments", "EasyComment:002" : "Users are only allowed to delete their own comments", "TotalComments" : "{0} comments", - "SubmitComment": "Submit", + "PublishComment": "Publish", "LeaveComment": "Leave Comment", "NeedCommentContent": "Please enter the content", "SuccessfullyPublishComment": "Comment published successfully", diff --git a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json index 1720bde..d92a607 100644 --- a/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json +++ b/src/EasyAbp.EasyComment.Domain.Shared/Localization/EasyComment/zh-Hans.json @@ -21,7 +21,7 @@ "EasyComment:001" : "用户只能更新自己的评论", "EasyComment:002" : "用户只能删除自己的评论", "TotalComments" : "共 {0} 条评论", - "SubmitComment": "提交评论", + "PublishComment": "发表", "LeaveComment": "发表评论", "NeedCommentContent": "请输入评论内容", "SuccessfullyPublishComment": "发表评论成功", diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml index bc700fd..016b8fc 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml @@ -26,18 +26,18 @@ - + @if (comment.CreatorId == CurrentUser.GetId()) { - @L["Edit"] + @L["Edit"] } - @L["Reply"] - @L["Reference"] + @L["Reply"] + @L["Reference"] @if (comment.CreatorId == CurrentUser.GetId()) { - @L["Remove"] + @L["Remove"] } @@ -52,10 +52,11 @@
- + } else { + // TODO }
\ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css index 313a773..b9a7ce0 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css @@ -16,6 +16,7 @@ .ec-content { line-break: anywhere; + white-space: pre-wrap; } .ec-comment-time { @@ -36,4 +37,9 @@ .dropdown-toggle::after { border: none; content: none; +} + +.ec-button-new-comment { + margin-bottom: 20px; + float: right; } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js index 1b1ff40..3cd849a 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js @@ -1,17 +1,21 @@ -$(function() { +$(function () { var l = abp.localization.getResource("EasyComment"); - + + var getEnclosedWidget = function (e) { + return e.closest(".abp-widget-wrapper"); + }; + $(".ec-button-new-comment").click(function (e) { e.preventDefault(); var form = e.currentTarget.closest("form"); if (!$(form).valid()) return; - var widgetWrapper = $(form).closest(".abp-widget-wrapper"); + var widget = getEnclosedWidget(form); var service = easyAbp.easyComment.comments.comment; - var itemType = $(widgetWrapper).find("#ItemType").val(); - var itemKey = $(widgetWrapper).find("#ItemKey").val(); - var content = $(widgetWrapper).find(".ec-textarea-new-comment").val(); + var itemType = $(widget).find("#ItemType").val(); + var itemKey = $(widget).find("#ItemKey").val(); + var content = $(widget).find(".ec-textarea-new-comment").val(); service.addComment({ itemType: itemType, @@ -21,10 +25,19 @@ }) .then(function () { abp.notify.info(l("SuccessfullyPublishComment")); - var widgetManager = new abp.WidgetManager($(widgetWrapper).parent()); + var widgetManager = new abp.WidgetManager($(widget).parent()); widgetManager.init(); widgetManager.refresh(); }); + }); + + $(".ec-edit-comment").click(function (e) { + var content = $(e.currentTarget).closest(".ec-comment").find("p.ec-content").text(); + var widget = getEnclosedWidget($(e.currentTarget)); + + var textarea = widget.find("textarea.ec-textarea-new-comment"); + textarea.val(content); + textarea.focus(); }) }) From 164ff993c18dbae4ad5392a76b3f72afc4317179 Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 17:03:51 +0800 Subject: [PATCH 5/9] Introduce `CommentEditorWidget` and `CommentViewerWidget` --- .../CommentEditorViewModel.cs | 15 +++++++++++++++ .../CommentEditorWidgetViewComponent.cs | 15 +++++++++++++++ .../CommentEditorWidget/Default.cshtml | 10 ++++++++++ .../CommentViewerViewModel.cs | 12 ++++++++++++ .../CommentViewerWidgetViewComponent.cs | 16 ++++++++++++++++ .../CommentViewerWidget/Default.cshtml | 3 +++ .../CommentWidget/CommentWidgetViewModel.cs | 11 ++--------- .../Components/CommentWidget/Default.cshtml | 17 ++++++++++++++--- 8 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/Default.cshtml diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs new file mode 100644 index 0000000..22263c5 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget +{ + public class CommentEditorViewModel + { + public bool ShowLabel { get; set; } + + [Required(ErrorMessage = "NeedCommentContent")] + [TextArea] + [Display(Name = "CommentContent")] + public string Content { get; set; } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs new file mode 100644 index 0000000..b311fc4 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.UI.Widgets; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget +{ + [Widget] + public class CommentEditorWidgetViewComponent : AbpViewComponent + { + public IViewComponentResult Invoke(CommentEditorViewModel viewModel) + { + return View(viewModel); + } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml new file mode 100644 index 0000000..810afca --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml @@ -0,0 +1,10 @@ +@using EasyAbp.EasyComment.Localization +@using Microsoft.AspNetCore.Mvc.Localization +@model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget.CommentEditorViewModel +@inject IHtmlLocalizer L + +@if (Model.ShowLabel) +{ + +} + \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs new file mode 100644 index 0000000..8353045 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs @@ -0,0 +1,12 @@ +using System; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget +{ + public class CommentViewerViewModel + { + public Guid Id { get; set; } + public string ItemType { get; set; } + public string ItemKey { get; set; } + public string Content { get; set; } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs new file mode 100644 index 0000000..d495896 --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs @@ -0,0 +1,16 @@ +using EasyAbp.EasyComment.Comments.Dtos; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.UI.Widgets; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget +{ + [Widget] + public class CommentViewerWidgetViewComponent : AbpViewComponent + { + public IViewComponentResult Invoke(CommentViewerViewModel viewModel) + { + return View(viewModel); + } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/Default.cshtml new file mode 100644 index 0000000..cf7585c --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/Default.cshtml @@ -0,0 +1,3 @@ +@model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget.CommentViewerViewModel + +

@Model.Content

\ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs index 28e364a..afb1fea 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs @@ -1,8 +1,6 @@ -using System.ComponentModel.DataAnnotations; -using EasyAbp.EasyComment.Comments.Dtos; +using EasyAbp.EasyComment.Comments.Dtos; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Dtos; -using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget { @@ -15,11 +13,6 @@ public class CommentWidgetViewModel public string ItemKey { get; set; } public PagedResultDto Comments { get; set; } - - [BindProperty] - [Required(ErrorMessage = "NeedCommentContent")] - [TextArea] - [Display(Name = "CommentContent")] - public string Content { get; set; } + } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml index 016b8fc..c57ba4d 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml @@ -1,5 +1,7 @@ @using EasyAbp.EasyComment.Comments.Dtos @using EasyAbp.EasyComment.Localization +@using EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget +@using EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Abp.Users @model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget.CommentWidgetViewModel @@ -43,15 +45,24 @@
-

@comment.Content

+ @await Component.InvokeAsync("CommentViewerWidget", new CommentViewerViewModel + { + Id = comment.Id, + ItemType = comment.ItemType, + ItemKey = comment.ItemKey, + Content = comment.Content, + })
} @if (CurrentUser.IsAuthenticated) {
- - + @await Component.InvokeAsync("CommentEditorWidget", new CommentEditorViewModel + { + ShowLabel = true, + Content = String.Empty, + }) } From 7a38594b5ba05da21541ae1c1ca2b890c828aee6 Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 18:27:24 +0800 Subject: [PATCH 6/9] Show comment editor --- .../Pages/Comments.cshtml | 2 +- .../CommentEditorViewModel.cs | 5 +++- .../CommentEditorWidgetController.cs | 16 ++++++++++ .../CommentEditorWidgetViewComponent.cs | 30 ++++++++++++++++--- .../CommentEditorWidget/Default.cshtml | 24 +++++++++++---- .../CommentViewerViewModel.cs | 2 -- .../CommentViewerWidgetController.cs | 16 ++++++++++ .../CommentViewerWidgetViewComponent.cs | 14 ++++++--- .../CommentsWidgetController.cs} | 4 +-- .../CommentsWidgetViewComponent.cs} | 12 ++++---- .../CommentsWidgetViewModel.cs} | 4 +-- .../Default.cshtml | 29 +++++++----------- .../Default.css | 6 +++- .../Default.js | 30 +++++++++++-------- 14 files changed, 135 insertions(+), 59 deletions(-) create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetController.cs create mode 100644 src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs rename src/EasyAbp.EasyComment.Web/Pages/Shared/Components/{CommentWidget/CommentWidgetController.cs => CommentsWidget/CommentsWidgetController.cs} (82%) rename src/EasyAbp.EasyComment.Web/Pages/Shared/Components/{CommentWidget/CommentWidgetViewComponent.cs => CommentsWidget/CommentsWidgetViewComponent.cs} (71%) rename src/EasyAbp.EasyComment.Web/Pages/Shared/Components/{CommentWidget/CommentWidgetViewModel.cs => CommentsWidget/CommentsWidgetViewModel.cs} (89%) rename src/EasyAbp.EasyComment.Web/Pages/Shared/Components/{CommentWidget => CommentsWidget}/Default.cshtml (74%) rename src/EasyAbp.EasyComment.Web/Pages/Shared/Components/{CommentWidget => CommentsWidget}/Default.css (89%) rename src/EasyAbp.EasyComment.Web/Pages/Shared/Components/{CommentWidget => CommentsWidget}/Default.js (56%) diff --git a/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml b/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml index cef09e4..a31fa00 100644 --- a/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml +++ b/host/EasyAbp.EasyComment.Web.Unified/Pages/Comments.cshtml @@ -3,7 +3,7 @@

Comments

- @await Component.InvokeAsync("CommentWidget", new + @await Component.InvokeAsync("CommentsWidget", new { ItemType = "TestItemType", ItemKey = "TestItemKey" diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs index 22263c5..e18d199 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorViewModel.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget @@ -11,5 +12,7 @@ public class CommentEditorViewModel [TextArea] [Display(Name = "CommentContent")] public string Content { get; set; } + + public bool EditModel { get; set; } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetController.cs new file mode 100644 index 0000000..eaef86f --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetController.cs @@ -0,0 +1,16 @@ +using System; +using Microsoft.AspNetCore.Mvc; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget +{ + [Route("/widgets/easyComment")] + public class CommentEditorWidgetController : EasyCommentController + { + [HttpGet] + [Route("showCommentEditor")] + public IActionResult ShowCommentEditor(Guid? id, bool showLabel, bool editModel) + { + return ViewComponent("CommentEditorWidget", new {id, showLabel, editModel}); + } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs index b311fc4..fac52fe 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/CommentEditorWidgetViewComponent.cs @@ -1,15 +1,37 @@ -using Microsoft.AspNetCore.Mvc; +using System; +using System.Threading.Tasks; +using EasyAbp.EasyComment.Comments; +using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget { - [Widget] + [Widget( + RefreshUrl = "/widgets/easyComment/showCommentEditor" + )] public class CommentEditorWidgetViewComponent : AbpViewComponent { - public IViewComponentResult Invoke(CommentEditorViewModel viewModel) + private readonly ICommentAppService _service; + + public CommentEditorWidgetViewComponent(ICommentAppService service) + { + _service = service; + } + + public async Task InvokeAsync(Guid? id, bool showLabel, bool editModel) { + var viewModel = new CommentEditorViewModel + { + ShowLabel = showLabel, + EditModel = editModel, + }; + if (id.HasValue) + { + var comment = await _service.GetAsync(id.Value); + viewModel.Content = comment.Content; + } return View(viewModel); - } + } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml index 810afca..30c78e1 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml @@ -3,8 +3,22 @@ @model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget.CommentEditorViewModel @inject IHtmlLocalizer L -@if (Model.ShowLabel) -{ - -} - \ No newline at end of file +
+ @if (Model.ShowLabel) + { + + } + + @if (Model.EditModel) + { +
+ + +
+ } + else + { + + } + +
\ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs index 8353045..6e125e1 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerViewModel.cs @@ -5,8 +5,6 @@ namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget public class CommentViewerViewModel { public Guid Id { get; set; } - public string ItemType { get; set; } - public string ItemKey { get; set; } public string Content { get; set; } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs new file mode 100644 index 0000000..22503ef --- /dev/null +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs @@ -0,0 +1,16 @@ +using System; +using Microsoft.AspNetCore.Mvc; + +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget +{ + [Route("/widgets/easyComment")] + public class CommentViewerWidgetController : EasyCommentController + { + [HttpGet] + [Route("showCommentViewer")] + public IActionResult ShowCommentViewer(Guid id, string content) + { + return ViewComponent("CommentViewerViewModel", new {id, content}); + } + } +} \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs index d495896..0e71e18 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs @@ -1,16 +1,22 @@ -using EasyAbp.EasyComment.Comments.Dtos; +using System; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget { - [Widget] + [Widget( + RefreshUrl = "/widgets/easyComment/showCommentViewer" + )] public class CommentViewerWidgetViewComponent : AbpViewComponent { - public IViewComponentResult Invoke(CommentViewerViewModel viewModel) + public IViewComponentResult Invoke(Guid id, string content) { - return View(viewModel); + return View(new CommentViewerViewModel + { + Id = id, + Content = content, + }); } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs similarity index 82% rename from src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs index 218aa01..406b5ae 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetController.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Mvc; -namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentsWidget { [Route("/widgets/easyComment")] - public class CommentWidgetController : EasyCommentController + public class CommentsWidgetController : EasyCommentController { [HttpGet] [Route("comments")] diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetViewComponent.cs similarity index 71% rename from src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetViewComponent.cs index e22a09e..b36c64f 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetViewComponent.cs @@ -5,18 +5,18 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentsWidget { [Widget( RefreshUrl = "/widgets/easyComment/comments", - ScriptFiles = new[]{"/Pages/Shared/Components/CommentWidget/Default.js"}, - StyleFiles = new[] {"/Pages/Shared/Components/CommentWidget/Default.css"} + ScriptFiles = new[]{"/Pages/Shared/Components/CommentsWidget/Default.js"}, + StyleFiles = new[] {"/Pages/Shared/Components/CommentsWidget/Default.css"} )] - public class CommentWidgetViewComponent : AbpViewComponent + public class CommentsWidgetViewComponent : AbpViewComponent { private readonly ICommentAppService _service; - public CommentWidgetViewComponent(ICommentAppService service) + public CommentsWidgetViewComponent(ICommentAppService service) { _service = service; } @@ -28,7 +28,7 @@ public async Task InvokeAsync(string itemType, string item ItemType = itemType, ItemKey = itemKey, }); - return View(new CommentWidgetViewModel + return View(new CommentsWidgetViewModel { ItemType = itemType, ItemKey = itemKey, diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetViewModel.cs similarity index 89% rename from src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetViewModel.cs index afb1fea..66234ca 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/CommentWidgetViewModel.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetViewModel.cs @@ -2,9 +2,9 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Dtos; -namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget +namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentsWidget { - public class CommentWidgetViewModel + public class CommentsWidgetViewModel { [HiddenInput] public string ItemType { get; set; } diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml similarity index 74% rename from src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml index c57ba4d..b6f62d3 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml @@ -4,7 +4,7 @@ @using EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Abp.Users -@model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentWidget.CommentWidgetViewModel +@model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentsWidget.CommentsWidgetViewModel @inject IHtmlLocalizer L @inject ICurrentUser CurrentUser @@ -17,7 +17,7 @@ @{ int i = 1; } @foreach (CommentDto comment in Model.Comments.Items) { - + @@ -32,7 +32,7 @@ @if (comment.CreatorId == CurrentUser.GetId()) { - @L["Edit"] + @L["Edit"] } @L["Reply"] @L["Reference"] @@ -45,26 +45,19 @@ - @await Component.InvokeAsync("CommentViewerWidget", new CommentViewerViewModel - { - Id = comment.Id, - ItemType = comment.ItemType, - ItemKey = comment.ItemKey, - Content = comment.Content, - }) +
+ @await Component.InvokeAsync("CommentViewerWidget", new {Id = comment.Id, Content = comment.Content,}) +

} @if (CurrentUser.IsAuthenticated) { -
- @await Component.InvokeAsync("CommentEditorWidget", new CommentEditorViewModel - { - ShowLabel = true, - Content = String.Empty, - }) - - + @await Component.InvokeAsync("CommentEditorWidget", new + { + ShowLabel = true, + Content = String.Empty, + }) } else { diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.css similarity index 89% rename from src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.css index b9a7ce0..3e6537f 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.css +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.css @@ -39,7 +39,11 @@ content: none; } -.ec-button-new-comment { +.ec-button-publish { margin-bottom: 20px; float: right; +} + +.ec-button-group-edit { + float : right; } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js similarity index 56% rename from src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js rename to src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js index 3cd849a..875f4d9 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentWidget/Default.js +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js @@ -1,17 +1,17 @@ $(function () { var l = abp.localization.getResource("EasyComment"); - var getEnclosedWidget = function (e) { - return e.closest(".abp-widget-wrapper"); + var getCommentWidget = function (e) { + return e.parents(".abp-widget-wrapper").last(); }; - - $(".ec-button-new-comment").click(function (e) { + + $(".ec-button-publish").click(function (e) { e.preventDefault(); - var form = e.currentTarget.closest("form"); + var form = $(this).closest("form"); if (!$(form).valid()) return; - var widget = getEnclosedWidget(form); + var widget = getCommentWidget(form); var service = easyAbp.easyComment.comments.comment; var itemType = $(widget).find("#ItemType").val(); var itemKey = $(widget).find("#ItemKey").val(); @@ -31,13 +31,17 @@ }); }); - $(".ec-edit-comment").click(function (e) { - var content = $(e.currentTarget).closest(".ec-comment").find("p.ec-content").text(); - var widget = getEnclosedWidget($(e.currentTarget)); - - var textarea = widget.find("textarea.ec-textarea-new-comment"); - textarea.val(content); - textarea.focus(); + $(".ec-edit-comment").click(function () { + var commentDiv = $(this).closest(".ec-comment"); + var commentId = commentDiv.attr("data-comment-id"); + + $.get("/widgets/easyComment/showCommentEditor", { + id: commentId, + showLabel: false, + editModel: true, + }, function (html) { + commentDiv.find(".ec-comment-holder").html(html); + }) }) }) From c4cee3260762449d2266370c8cfb3603a09fcbb2 Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 19:41:13 +0800 Subject: [PATCH 7/9] Confirm on cancelling edit --- .../CommentViewerWidgetController.cs | 4 +-- .../CommentViewerWidgetViewComponent.cs | 16 ++++++++- .../CommentsWidgetController.cs | 2 +- .../Components/CommentsWidget/Default.js | 36 ++++++++++++++++--- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs index 22503ef..6622ca6 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs @@ -8,9 +8,9 @@ public class CommentViewerWidgetController : EasyCommentController { [HttpGet] [Route("showCommentViewer")] - public IActionResult ShowCommentViewer(Guid id, string content) + public IActionResult ShowCommentViewer(Guid id, string content, bool refreshData) { - return ViewComponent("CommentViewerViewModel", new {id, content}); + return ViewComponent("CommentViewerWidget", new {id, content, refreshData}); } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs index 0e71e18..9f46378 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs @@ -1,4 +1,6 @@ using System; +using System.Threading.Tasks; +using EasyAbp.EasyComment.Comments; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; @@ -10,8 +12,20 @@ namespace EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentViewerWidget )] public class CommentViewerWidgetViewComponent : AbpViewComponent { - public IViewComponentResult Invoke(Guid id, string content) + private readonly ICommentAppService _service; + + public CommentViewerWidgetViewComponent(ICommentAppService service) + { + _service = service; + } + + public async Task InvokeAsync(Guid id, string content, bool refreshData) { + if (refreshData) + { + var comment = await _service.GetAsync(id); + content = comment.Content; + } return View(new CommentViewerViewModel { Id = id, diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs index 406b5ae..7e6005e 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/CommentsWidgetController.cs @@ -9,7 +9,7 @@ public class CommentsWidgetController : EasyCommentController [Route("comments")] public IActionResult Comments(string itemType, string itemKey) { - return ViewComponent("CommentWidget", new {itemType, itemKey}); + return ViewComponent("CommentsWidget", new {itemType, itemKey}); } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js index 875f4d9..fca3563 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.js @@ -4,7 +4,7 @@ var getCommentWidget = function (e) { return e.parents(".abp-widget-wrapper").last(); }; - + $(".ec-button-publish").click(function (e) { e.preventDefault(); @@ -31,17 +31,45 @@ }); }); + $(document).on("change", "form :input", function () { + $(this).closest('form').data('changed', true); + }) + $(".ec-edit-comment").click(function () { var commentDiv = $(this).closest(".ec-comment"); + var commentHolder = commentDiv.find(".ec-comment-holder"); var commentId = commentDiv.attr("data-comment-id"); - + + commentHolder.find("[data-widget-name=CommentViewerWidget]").hide(); $.get("/widgets/easyComment/showCommentEditor", { id: commentId, showLabel: false, editModel: true, }, function (html) { - commentDiv.find(".ec-comment-holder").html(html); + commentDiv.find(".ec-comment-holder").append(html); }) - }) + }); + + $(document).on("click", ".ec-button-cancel", function () { + var btnCancel = $(this); + + var cancelEdit = function () { + var commentDiv = btnCancel.closest(".ec-comment"); + var commentHolder = commentDiv.find(".ec-comment-holder"); + commentHolder.find("[data-widget-name=CommentViewerWidget]").show(); + commentHolder.find("[data-widget-name=CommentEditorWidget]").remove(); + } + + if ($(this).closest('form').data('changed')) { + abp.message.confirm(l("AreYouSureYouWantToCancelEditingWarningMessage")) + .done(function (result) { + if (result) { + cancelEdit(); + } + }) + } else { + cancelEdit(); + } + }); }) From efa42349b31b99c3c38136ea2f0c3d2e1cfb78bd Mon Sep 17 00:00:00 2001 From: wakuflair Date: Tue, 30 Jun 2020 19:57:34 +0800 Subject: [PATCH 8/9] Omit dropdown menus if not login --- .../CommentEditorWidget/Default.cshtml | 2 +- .../CommentViewerWidgetController.cs | 4 +- .../CommentViewerWidgetViewComponent.cs | 4 +- .../Components/CommentsWidget/Default.cshtml | 37 ++++++++++--------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml index 30c78e1..d0c30a1 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentEditorWidget/Default.cshtml @@ -3,7 +3,7 @@ @model EasyAbp.EasyComment.Web.Pages.Shared.Components.CommentEditorWidget.CommentEditorViewModel @inject IHtmlLocalizer L -
+ @if (Model.ShowLabel) { diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs index 6622ca6..45af749 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetController.cs @@ -8,9 +8,9 @@ public class CommentViewerWidgetController : EasyCommentController { [HttpGet] [Route("showCommentViewer")] - public IActionResult ShowCommentViewer(Guid id, string content, bool refreshData) + public IActionResult ShowCommentViewer(Guid id, string content, bool fromServer) { - return ViewComponent("CommentViewerWidget", new {id, content, refreshData}); + return ViewComponent("CommentViewerWidget", new {id, content, fromServer}); } } } \ No newline at end of file diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs index 9f46378..b5fa948 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentViewerWidget/CommentViewerWidgetViewComponent.cs @@ -19,9 +19,9 @@ public CommentViewerWidgetViewComponent(ICommentAppService service) _service = service; } - public async Task InvokeAsync(Guid id, string content, bool refreshData) + public async Task InvokeAsync(Guid id, string content, bool fromServer) { - if (refreshData) + if (fromServer) { var comment = await _service.GetAsync(id); content = comment.Content; diff --git a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml index b6f62d3..48833f1 100644 --- a/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml +++ b/src/EasyAbp.EasyComment.Web/Pages/Shared/Components/CommentsWidget/Default.cshtml @@ -27,26 +27,29 @@ - - - - @if (comment.CreatorId == CurrentUser.GetId()) - { - @L["Edit"] - } - @L["Reply"] - @L["Reference"] - @if (comment.CreatorId == CurrentUser.GetId()) - { - - @L["Remove"] - } - - + @if (CurrentUser.IsAuthenticated) + { + + + + @if (comment.CreatorId == CurrentUser.GetId()) + { + @L["Edit"] + } + @L["Reply"] + @L["Reference"] + @if (comment.CreatorId == CurrentUser.GetId()) + { + + @L["Remove"] + } + + + }
- @await Component.InvokeAsync("CommentViewerWidget", new {Id = comment.Id, Content = comment.Content,}) + @await Component.InvokeAsync("CommentViewerWidget", new {Id = comment.Id, Content = comment.Content, FromServer = false})

From 4951ef792647d0daae4c0e4de54934dc54df9482 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2020 12:00:20 +0000 Subject: [PATCH 9/9] Bump mixin-deep in /host/EasyAbp.EasyComment.IdentityServer Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases) - [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2) Signed-off-by: dependabot[bot] --- host/EasyAbp.EasyComment.IdentityServer/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/EasyAbp.EasyComment.IdentityServer/yarn.lock b/host/EasyAbp.EasyComment.IdentityServer/yarn.lock index f4162d3..b27e5ce 100644 --- a/host/EasyAbp.EasyComment.IdentityServer/yarn.lock +++ b/host/EasyAbp.EasyComment.IdentityServer/yarn.lock @@ -1637,9 +1637,9 @@ minizlib@^1.2.1: minipass "^2.2.1" mixin-deep@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" - integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== dependencies: for-in "^1.0.2" is-extendable "^1.0.1"