From 1b86dba8d6b8ca8f9aa6c3f96d47666fe0798a8e Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 31 Aug 2020 16:29:38 +0300 Subject: [PATCH] cmskit comments reply button and textbox placement --- .../Components/Commenting/Default.cshtml | 187 +++++++++--------- .../Shared/Components/Commenting/default.js | 7 +- 2 files changed, 99 insertions(+), 95 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml index ffedf136d9..8cf2878d16 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml @@ -15,96 +15,99 @@ @{ Func GetCommentTitle(CmsUserDto author, DateTime creationTime) => - @ - - @((string.IsNullOrWhiteSpace(author.Name) + @ + + @((string.IsNullOrWhiteSpace(author.Name) ? author.UserName : author.Name + " " + author.Surname).Trim()) - @creationTime.ToString() - ; + @creationTime.ToString() + ; } @{ Func GetCommentArea(Guid? repliedCommentId, bool cancelButton = false) => - @
-
- -
-
-
- + @
+ + +
+
+
+ +
-
-
-
- @if (cancelButton) - { - @L["Cancel"] - } - @L["Send"] +
+
+ @if (cancelButton) + { + + @L["Cancel"] + + } + + @L["Send"] + +
-
- -
; + +
; } @{ Func GetCommentContentArea(Guid id, string text) => - @
-
-

- @text -

-
-
; + @
+
+

+ @text +

+
+
; } @{ Func GetCommentActionArea(Guid id, Guid authorId, bool isReply, string text) => - @
-
- @if (!isReply) - { - @if (CurrentUser.IsAuthenticated) + @
+
+ @if (!isReply) { - - @L["Reply"] - + @if (CurrentUser.IsAuthenticated) + { + + @L["Reply"] + + } + else + { + @L["LoginToReply"] + } } - else + @if (authorId == CurrentUser.Id) { - @L["LoginToReply"] - } - } - @if (authorId == CurrentUser.Id) - { - - - @L["Delete"] - + + @L["Delete"] + - - @L["Edit"] - - } -
- + -
; +
; }
@@ -112,20 +115,7 @@
@L["Comments"]
-
- @if (CurrentUser.IsAuthenticated) - { -
- @GetCommentArea(null).Invoke(null) -
- } - else if (!string.IsNullOrWhiteSpace(Model.LoginUrl)) - { - - } -
+ @foreach (var comment in Model.Comments) {
@@ -138,17 +128,11 @@ @if (cmsKitUiOptions.Value.CommentsOptions.IsReactionsEnabled && GlobalFeatureManager.Instance.IsEnabled()) { - @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), - new { entityType = "comment", entityId = comment.Id.ToString() }) + @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new {entityType = "comment", entityId = comment.Id.ToString()}) } @GetCommentActionArea(comment.Id, comment.Author.Id, false, comment.Text).Invoke(null) - @if (CurrentUser.IsAuthenticated) - { - @GetCommentArea(comment.Id, true).Invoke(null) - } - @if (comment.Replies.Any()) { @foreach (var reply in comment.Replies) @@ -165,8 +149,7 @@ @if (cmsKitUiOptions.Value.CommentsOptions.IsReactionsEnabled && GlobalFeatureManager.Instance.IsEnabled()) { - @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), - new { entityType = "comment", entityId = reply.Id.ToString() }) + @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new {entityType = "comment", entityId = reply.Id.ToString()}) } @GetCommentActionArea(reply.Id, reply.Author.Id, true, reply.Text).Invoke(null) @@ -174,7 +157,27 @@
} + @if (comment.Replies.Count >= 5) + { +
+ @if (CurrentUser.IsAuthenticated) + { + + @L["Reply"] + + } + else + { + @L["LoginToReply"] + } +
+ } } + @if (CurrentUser.IsAuthenticated) + { + @GetCommentArea(comment.Id, true).Invoke(null) + } +
} 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 2e6c8e0dac..99e6167b49 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 @@ -58,10 +58,11 @@ var replyCommentId = $link.data('reply-id'); var $relatedCommentArea = $container.find('.cms-comment-form-area[data-reply-id=' + replyCommentId + ']'); + var $links = $container.find('.comment-reply-link[data-reply-id=' + replyCommentId + ']'); $relatedCommentArea.show(); $relatedCommentArea.find('textarea').focus(); - $link.removeAttr('href'); + $links.addClass('disabled'); }); }); $container.find('.reply-cancel-button').each(function () { @@ -72,10 +73,10 @@ var replyCommentId = $button.data('reply-id'); var $relatedCommentArea = $container.find('.cms-comment-form-area[data-reply-id=' + replyCommentId + ']'); - var $replyLink = $container.find('.comment-reply-link[data-reply-id=' + replyCommentId + ']'); + var $links = $container.find('.comment-reply-link[data-reply-id=' + replyCommentId + ']'); $relatedCommentArea.hide(); - $replyLink.attr('href', '#'); + $links.removeClass('disabled'); }); }); }