Skip to content

Commit 19248e3

Browse files
committed
Update TagHelpers and scripts to make it easier to land on the correct comments admin page when mananging comments.
1 parent 45355a4 commit 19248e3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

source/DasBlog.Web.UI/TagHelpers/Comments/CommentApprovalLinkTagHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public CommentApprovalLinkTagHelper(IDasBlogSettings dasBlogSettings)
2323

2424
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
2525
{
26-
var approvalurl = string.Format(COMMENTAPPROVE_URL, dasBlogSettings.GetPermaLinkUrl(Comment.BlogPostId), Comment.CommentId);
2726
var commenttxt = string.Format(COMMENTTEXT_MSG, Comment.Name);
2827
var message = "Comment Approved";
2928
var admin = string.Empty;
@@ -35,7 +34,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
3534

3635
output.TagName = "a";
3736
output.TagMode = TagMode.StartTagAndEndTag;
38-
output.Attributes.SetAttribute("href", $"javascript:commentManagement(\"{approvalurl}\",\"{commenttxt}\",\"PATCH\",\"{admin}\")");
37+
output.Attributes.SetAttribute("href", $"javascript:commentManagement(\"{Comment.BlogPostId}\",\"{Comment.CommentId}\",\"{commenttxt}\",\"PATCH\",\"{admin}\")");
3938
output.Attributes.SetAttribute("class", "dbc-comment-approve-link");
4039

4140
var content = await output.GetChildContentAsync();

source/DasBlog.Web.UI/TagHelpers/Comments/CommentDeleteLinkTagHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ public CommentDeleteLinkTagHelper(IDasBlogSettings dasBlogSettings)
2525

2626
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
2727
{
28-
var deleteurl = string.Format(COMMENTDELETE_URL, dasBlogSettings.GetPermaLinkUrl(Comment.BlogPostId), Comment.CommentId);
2928
var commenttxt = string.Format(COMMENTTEXT_MSG, Comment.Name);
3029
var admin = string.Empty;
31-
string message = "Delete Comment";
30+
var message = "Delete Comment";
3231

3332
if (Admin)
3433
{
@@ -37,7 +36,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
3736

3837
output.TagName = "a";
3938
output.TagMode = TagMode.StartTagAndEndTag;
40-
output.Attributes.SetAttribute("href", $"javascript:commentManagement(\"{deleteurl}\",\"{commenttxt}\",\"DELETE\",\"{admin}\")");
39+
output.Attributes.SetAttribute("href", $"javascript:commentManagement(\"{Comment.BlogPostId}\",\"{Comment.CommentId}\",\"{commenttxt}\",\"DELETE\",\"{admin}\")");
4140
output.Attributes.SetAttribute("class", "dbc-comment-delete-link");
4241

4342
var content = await output.GetChildContentAsync();

source/DasBlog.Web.UI/wwwroot/js/site.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11

2-
function commentManagement(url, commentText, httpVerb, adminhref) {
2+
function commentManagement(postid, commentid, commentText, httpVerb, adminhref) {
33
if (confirm(commentText)) {
44
var oReq = new XMLHttpRequest();
5+
6+
url = 'post/' + postid + '/comments/' + commentid;
57

68
oReq.onreadystatechange = function () {
79
if (this.readyState == 4 && this.status == 200) {
810

911
if (adminhref.length != 0) {
10-
url = "admin/manage-comments";
12+
url = 'admin/manage-comments/' + postid;
1113
}
12-
1314
location.href = url;
15+
1416
}
1517
};
1618

0 commit comments

Comments
 (0)