From 736845063e5e37f08b05d4b828929dd3d106ae8e Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 4 Oct 2018 10:39:30 +0300 Subject: [PATCH] issue #452 --- .../Resources/Blogging/Web/en.json | 1 + .../Resources/Blogging/Web/tr.json | 1 + .../Pages/Blog/Posts/Detail.cshtml | 14 +++++++---- .../Pages/Blog/Posts/Detail.cshtml.cs | 7 +++++- .../Pages/Blog/Posts/detail.js | 23 ++++++++++++++++--- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json index 17612e8fa2..b9e7b543b9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json +++ b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json @@ -6,6 +6,7 @@ "Title": "Title", "Delete": "Delete", "Reply": "Reply", + "ReplyTo": "Reply To {0}", "ContinueReading": "Continue Reading", "DaysAgo": "{0} days ago", "YearsAgo": "{0} years ago", diff --git a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json index e5e8adc60d..a5a705d506 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json +++ b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json @@ -5,6 +5,7 @@ "Title": "Başlık", "Delete": "Sil", "Reply": "Yanıtla", + "ReplyTo": "{0}'a cevap ver", "Menu:BlogManagement": "Blog Yönetimi", "ContinueReading": "Devamı...", "DaysAgo": "{0} Gün Önce", diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml index f3e2728de0..4d560ee5af 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml @@ -23,6 +23,9 @@ } + + +
@@ -173,8 +176,8 @@

- @L["ReplyTo"] - @(commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName) + @L["ReplyTo", commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName] +

@@ -185,6 +188,7 @@
+
@@ -201,6 +205,7 @@
+
@@ -249,8 +254,7 @@

- @L["ReplyTo"] - @(commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName) + @L["ReplyTo",commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName]

@@ -260,6 +264,7 @@
+
@@ -276,6 +281,7 @@ + diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs index 7e02cd8d3a..953c3aa8a1 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs @@ -31,6 +31,9 @@ namespace Volo.Blogging.Pages.Blog.Posts public int CommentCount { get; set; } + [HiddenInput] + public Guid FocusCommentId { get; set; } + public PostWithDetailsDto Post { get; set; } public IReadOnlyList CommentsWithReplies { get; set; } @@ -51,13 +54,15 @@ namespace Volo.Blogging.Pages.Blog.Posts public async Task OnPostAsync() { - await _commentAppService.CreateAsync(new CreateCommentDto() + var comment = await _commentAppService.CreateAsync(new CreateCommentDto() { RepliedCommentId = NewComment.RepliedCommentId, PostId = NewComment.PostId, Text = NewComment.Text }); + FocusCommentId = comment.Id; + await GetData(); } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js index 7b042fd79a..1ab4ba1167 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js @@ -3,6 +3,7 @@ var l = abp.localization.getResource('Blogging'); $('div .replyForm').hide(); + $('div .editForm').hide(); $('form[class="editFormClass"]').submit(function (event) { @@ -25,6 +26,16 @@ }); }); + $('.editCancelButton').click(function (event) { + event.preventDefault(); + $('div .editForm').hide(); + }); + + $('.replyCancelButton').click(function (event) { + event.preventDefault(); + $('div .replyForm').hide(); + }); + $('.replyLink').click(function (event) { event.preventDefault(); $('div .editForm').hide(); @@ -44,7 +55,7 @@ } }); - $('.deleteLink').click(function(event) { + $('.deleteLink').click(function (event) { event.preventDefault(); var linkElement = $(this); var deleteCommentId = linkElement.attr('data-deleteid'); @@ -53,7 +64,7 @@ abp.message.confirm( l('CommentDeletionWarningMessage'), // TODO: localize l('Are you sure?'), - function(isConfirmed) { + function (isConfirmed) { if (isConfirmed) { $.ajax({ type: "POST", @@ -79,7 +90,7 @@ abp.message.confirm( l('PostDeletionWarningMessage'), // TODO: localize l('AreYouSure'), - function(isConfirmed) { + function (isConfirmed) { if (isConfirmed) { $.ajax({ type: "POST", @@ -119,4 +130,10 @@ } }); + if ($('#FocusCommentId').val() != '00000000-0000-0000-0000-000000000000') { + $('html, body').animate({ + scrollTop: ($('#' + $('#FocusCommentId').val()).offset().top - 150) + }, 500); + } + })(jQuery);