From e747d09b7f356949e2cd8f3a982e76b52f290dac Mon Sep 17 00:00:00 2001 From: xRy0 Date: Wed, 21 May 2025 18:41:46 +0300 Subject: [PATCH] feat(FeedReports): oldpost button + moved reportPost() js function to al_feed.js --- Web/Presenters/templates/Wall/Post.xml | 25 +------------------ .../templates/components/post/oldpost.xml | 6 ++++- Web/static/js/al_feed.js | 23 +++++++++++++++++ 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Web/Presenters/templates/Wall/Post.xml b/Web/Presenters/templates/Wall/Post.xml index 3d136ebd..2e08f70f 100644 --- a/Web/Presenters/templates/Wall/Post.xml +++ b/Web/Presenters/templates/Wall/Post.xml @@ -56,29 +56,6 @@ > {_changes_history} - {_report} + {_report} - {/block} diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 7c86382a..bece0c51 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -138,7 +138,11 @@ {if $feedIgnoreButton && !$canBeDeleted} {_feed_ignore}  |  {/if} - + + {if !$canBeDeleted} + {_report}  |  + {/if} + {if !($forceNoPinLink ?? false) && $canBePinned} {if $post->isPinned()} {_unpin} diff --git a/Web/static/js/al_feed.js b/Web/static/js/al_feed.js index c35161bc..14fb2385 100644 --- a/Web/static/js/al_feed.js +++ b/Web/static/js/al_feed.js @@ -353,3 +353,26 @@ function openJsSettings() { `) } + + +function reportPost(postId) { + uReportMsgTxt = tr("going_to_report_post"); + uReportMsgTxt += "
"+tr("report_question_text"); + uReportMsgTxt += "

"+tr("report_reason")+": " + + MessageBox(tr("report_question"), uReportMsgTxt, [tr("confirm_m"), tr("cancel")], [ + (function() { + res = document.querySelector("#uReportMsgInput").value; + xhr = new XMLHttpRequest(); + xhr.open("GET", "/report/" + postId + "?reason=" + res + "&type=post", true); + xhr.onload = (function() { + if(xhr.responseText.indexOf("reason") === -1) + MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]); + else + MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]); + }); + xhr.send(null); + }), + Function.noop + ]); + } \ No newline at end of file