use postToast in delete_comment_modal
parent
2fd63d7474
commit
0e10dd6b32
|
@ -95,14 +95,12 @@ function toggleEdit(id){
|
|||
};
|
||||
|
||||
|
||||
function delete_commentModal(id) {
|
||||
function delete_commentModal(t, id) {
|
||||
document.getElementById("deleteCommentButton").onclick = function() {
|
||||
const xhr = createXhrWithFormKey(`/delete/comment/${id}`);
|
||||
xhr[0].onload = function() {
|
||||
let data
|
||||
try {data = JSON.parse(xhr[0].response)}
|
||||
catch(e) {console.log(e)}
|
||||
if (xhr[0].status >= 200 && xhr[0].status < 300 && data && data['message']) {
|
||||
postToast(t, `/delete/comment/${id}`,
|
||||
{
|
||||
},
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/comments')
|
||||
{
|
||||
document.getElementById("post-info-"+id).remove()
|
||||
|
@ -116,12 +114,8 @@ function delete_commentModal(id) {
|
|||
document.getElementById(`delete2-${id}`).classList.add('d-none');
|
||||
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
|
||||
}
|
||||
showToast(true, getMessageFromJsonData(true, data));
|
||||
} else {
|
||||
showToast(false, getMessageFromJsonData(false, data));
|
||||
}
|
||||
};
|
||||
xhr[0].send(xhr[1]);
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -428,7 +428,7 @@
|
|||
|
||||
<button type="button" id="undelete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if not c.deleted_utc %}d-none{% endif %}" onclick="postToastSwitch(this,'/undelete/comment/{{c.id}}','delete-{{c.id}}','undelete-{{c.id}}','d-none');document.getElementById('comment-{{c.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt fa-fw"></i>Undelete</button>
|
||||
|
||||
<button type="button" id="delete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if c.deleted_utc %}d-none{% endif %}" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="fas fa-trash-alt fa-fw"></i>Delete</button>
|
||||
<button type="button" id="delete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if c.deleted_utc %}d-none{% endif %}" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal(this, '{{c.id}}')"><i class="fas fa-trash-alt fa-fw"></i>Delete</button>
|
||||
{% elif v and c.body %}
|
||||
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" onclick="expandMarkdown('{{c.id}}','c')"><i class="fas text-expand-icon-{{c.id}} fa-expand-alt"></i><span class="expand-text-c-{{c.id}}">View source</span></button>
|
||||
{% endif %}
|
||||
|
@ -636,7 +636,7 @@
|
|||
|
||||
<button type="button" id="undelete2-{{c.id}}" class="{% if not c.deleted_utc %}d-none{% endif %} list-group-item text-success" onclick="postToastSwitch(this,'/undelete/comment/{{c.id}}', 'delete2-{{c.id}}', 'undelete2-{{c.id}}','d-none');document.getElementById('comment-{{c.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-success mr-2"></i>Undelete</button>
|
||||
|
||||
<button type="button" id="delete2-{{c.id}}" class="{% if c.deleted_utc %}d-none{% endif %} list-group-item text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="far fa-trash-alt text-danger mr-2"></i>Delete</button>
|
||||
<button type="button" id="delete2-{{c.id}}" class="{% if c.deleted_utc %}d-none{% endif %} list-group-item text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal(this, '{{c.id}}')"><i class="far fa-trash-alt text-danger mr-2"></i>Delete</button>
|
||||
{% else %}
|
||||
{% if c.body %}
|
||||
<button type="button" data-bs-dismiss="modal" onclick="expandMarkdown('{{c.id}}','c')" class="list-group-item"><i class="fas text-expand-icon-{{c.id}} fa-expand-alt mr-2"></i><span class="expand-text-c-{{c.id}}">View source</span></button>
|
||||
|
|
Loading…
Reference in New Issue