change reporting flow

remotes/1693045480750635534/spooky-22
Aevann1 2022-09-07 03:22:40 +02:00
parent bc2d1fb53f
commit 05bacd1efc
5 changed files with 28 additions and 29 deletions

View File

@ -17,7 +17,6 @@ function report_commentModal(id, author) {
document.getElementById("comment-author").textContent = author;
document.getElementById("reportCommentFormBefore").classList.remove('d-none');
document.getElementById("reportCommentFormAfter").classList.add('d-none');
reportCommentButton.innerHTML='Report comment';
reportCommentButton.disabled = false;
@ -39,9 +38,19 @@ function report_commentModal(id, author) {
form.append("formkey", formkey());
form.append("reason", reason_comment.value);
xhr.onload=function() {
document.getElementById("reportCommentFormBefore").classList.add('d-none');
document.getElementById("reportCommentFormAfter").classList.remove('d-none');
xhr.onload = function() {
let data
try {data = JSON.parse(xhr.response)}
catch(e) {console.log(e)}
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
document.getElementById("reportCommentFormBefore").classList.add('d-none');
document.getElementById('toast-post-success-text').innerText = data["message"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show();
} else {
document.getElementById('toast-post-error-text').innerText = "Error, please try again later."
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show();
}
};
xhr.onerror=function(){alert(errortext)};

View File

@ -14,7 +14,6 @@ reason_post.addEventListener('keydown', (e) => {
function report_postModal(id) {
document.getElementById("reportPostFormBefore").classList.remove('d-none');
document.getElementById("reportPostFormAfter").classList.add('d-none');
reportPostButton.disabled = false;
reportPostButton.classList.remove('disabled');
reportPostButton.innerHTML='Report post';
@ -37,9 +36,19 @@ function report_postModal(id) {
form.append("formkey", formkey());
form.append("reason", reason_post.value);
xhr.onload=function() {
document.getElementById("reportPostFormBefore").classList.add('d-none');
document.getElementById("reportPostFormAfter").classList.remove('d-none');
xhr.onload = function() {
let data
try {data = JSON.parse(xhr.response)}
catch(e) {console.log(e)}
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
document.getElementById("reportPostFormBefore").classList.add('d-none');
document.getElementById('toast-post-success-text').innerText = data["message"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show();
} else {
document.getElementById('toast-post-error-text').innerText = "Error, please try again later."
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show();
}
};
xhr.onerror=function(){alert(errortext)};

View File

@ -811,16 +811,6 @@
<button id="reportCommentButton" class="btn btn-danger">Report comment</button>
</div>
</div>
<div class="d-none" id="reportCommentFormAfter">
<div class="modal-body">
<div class="h6">Thank you for reporting this comment!</div>
<small class="form-text text-muted">We'll take it from here.</small>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>

View File

@ -19,17 +19,8 @@
<button id="reportPostButton" class="btn btn-danger">Report post</button>
</div>
</div>
<div class="d-none" id="reportPostFormAfter">
<div class="modal-body">
<div class="h6">Thank you for reporting this post!</div>
<small class="form-text text-muted">We'll take it from here.</small>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script src="/assets/js/report_post_modal.js?v=4000"></script>
<script src="/assets/js/report_post_modal.js?v=4001"></script>

View File

@ -19,7 +19,7 @@ set CACHE_VER = {
'js/bootstrap.js': 4000,
'js/category_modal.js': 4000,
'js/comments_admin.js': 4000,
'js/comments_v.js': 4000,
'js/comments_v.js': 4001,
'js/submission_listing.js': 4000,
'js/emoji_modal.js': 4001,
'js/formatting.js': 4000,