forked from rDrama/rDrama
use postToast in delete_post_modal
parent
82579cdb71
commit
599729f54a
|
@ -1,13 +1,9 @@
|
||||||
function delete_postModal(id) {
|
function delete_postModal(t, id) {
|
||||||
document.getElementById("deletePostButton").onclick = function() {
|
document.getElementById("deletePostButton").onclick = function() {
|
||||||
const xhr = createXhrWithFormKey(`/delete_post/${id}`);
|
postToast(t, `/delete_post/${id}`,
|
||||||
xhr[0].onload = function() {
|
{
|
||||||
let data
|
},
|
||||||
try {data = JSON.parse(xhr[0].response)}
|
() => {
|
||||||
catch(e) {console.log(e)}
|
|
||||||
success = xhr[0].status >= 200 && xhr[0].status < 300;
|
|
||||||
showToast(success, getMessageFromJsonData(success, data));
|
|
||||||
if (success && data["message"]) {
|
|
||||||
if (window.location.pathname == '/admin/reported/posts')
|
if (window.location.pathname == '/admin/reported/posts')
|
||||||
{
|
{
|
||||||
document.getElementById("flaggers-"+id).remove()
|
document.getElementById("flaggers-"+id).remove()
|
||||||
|
@ -21,10 +17,7 @@ function delete_postModal(id) {
|
||||||
document.getElementById(`delete2-${id}`).classList.add('d-none');
|
document.getElementById(`delete2-${id}`).classList.add('d-none');
|
||||||
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
|
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
showToast(false, getMessageFromJsonData(false, data));
|
|
||||||
}
|
}
|
||||||
};
|
);
|
||||||
xhr[0].send(xhr[1]);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
<button type="button" id="undelete2-{{p.id}}" class="{% if not p.deleted_utc %}d-none{% endif %} list-inline-item" onclick="postToastSwitch(this,'/undelete_post/{{p.id}}', 'delete2-{{p.id}}', 'undelete2-{{p.id}}','d-none');document.getElementById('post-{{p.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt"></i>Undelete</button>
|
<button type="button" id="undelete2-{{p.id}}" class="{% if not p.deleted_utc %}d-none{% endif %} list-inline-item" onclick="postToastSwitch(this,'/undelete_post/{{p.id}}', 'delete2-{{p.id}}', 'undelete2-{{p.id}}','d-none');document.getElementById('post-{{p.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt"></i>Undelete</button>
|
||||||
|
|
||||||
<button type="button" id="delete2-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} list-inline-item" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal('{{p.id}}')"><i class="fas fa-trash-alt"></i>Delete</button>
|
<button type="button" id="delete2-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} list-inline-item" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal(this, '{{p.id}}')"><i class="fas fa-trash-alt"></i>Delete</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<button type="button" id="undelete-{{p.id}}" class="{% if not p.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" onclick="postToastSwitch(this,'/undelete_post/{{p.id}}', 'delete-{{p.id}}', 'undelete-{{p.id}}','d-none');document.getElementById('post-{{p.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-center mr-2"></i>Undelete</button>
|
<button type="button" id="undelete-{{p.id}}" class="{% if not p.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" onclick="postToastSwitch(this,'/undelete_post/{{p.id}}', 'delete-{{p.id}}', 'undelete-{{p.id}}','d-none');document.getElementById('post-{{p.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-center mr-2"></i>Undelete</button>
|
||||||
|
|
||||||
<button type="button" id="delete-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal('{{p.id}}')"><i class="far fa-trash-alt mr-2"></i>Delete</button>
|
<button type="button" id="delete-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal(this, '{{p.id}}')"><i class="far fa-trash-alt mr-2"></i>Delete</button>
|
||||||
|
|
||||||
|
|
||||||
{% if FEATURES['COUNTRY_CLUB'] -%}
|
{% if FEATURES['COUNTRY_CLUB'] -%}
|
||||||
|
|
Loading…
Reference in New Issue