73 lines
3.3 KiB
HTML
73 lines
3.3 KiB
HTML
{{ define "delete_clan" }}
|
|
|
|
<div class="modal modal-lg fade" id="deleteClanModal" tabindex="-1">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title fs-3 text-danger fw-bold" id="deleteClanModalLabel">Clan löschen</h1>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body fs-5">
|
|
Möchtest du den Clan "<span id="clan"></span>" wirklich löschen?
|
|
<br><br>
|
|
Diese Aktion kann nicht rückgängig gemacht werden.
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="submit" name="submit" class="btn btn-lg btn-danger">Löschen</button>
|
|
<button type="button" class="btn btn-lg btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script lang="javascript">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const deleteClanModal = document.getElementById('deleteClanModal')
|
|
const deleteClanModalBS = new bootstrap.Modal('#deleteClanModal');
|
|
if (deleteClanModal) {
|
|
deleteClanModal.addEventListener('show.bs.modal', event => {
|
|
const [clanList, otherClanList] = getClanLists(event);
|
|
|
|
const selectedClan = clanList.options[clanList.selectedIndex].text;
|
|
const modalBodyInput = deleteClanModal.querySelector('#clan');
|
|
modalBodyInput.innerText = selectedClan;
|
|
|
|
const submitButton = deleteClanModal.querySelector('button[name="submit"]');
|
|
submitButton.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
submitButton.onclick = function () {}
|
|
|
|
const clanId = parseInt(clanList.value);
|
|
|
|
fetch("/clan/" + clanId, {
|
|
method: "DELETE",
|
|
headers: {
|
|
"Content-type": "application/json; charset=UTF-8"
|
|
}
|
|
})
|
|
.then((response) => {
|
|
if (response.ok) {
|
|
const clanToRemove = clanList.children[clanList.selectedIndex];
|
|
const clanIndex = clanToRemove.index;
|
|
clanList.removeChild(clanToRemove);
|
|
clanList.selectedIndex = 0;
|
|
clanList.dispatchEvent(new Event('change'));
|
|
|
|
const lastOtherIndex = otherClanList.selectedIndex;
|
|
otherClanList.children.item(clanIndex).remove();
|
|
if (lastOtherIndex === clanIndex) {
|
|
otherClanList.selectedIndex = 0;
|
|
otherClanList.dispatchEvent(new Event('change'));
|
|
}
|
|
|
|
deleteClanModalBS.hide();
|
|
} else
|
|
throw new Error(response.error)
|
|
});
|
|
})
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
{{ end }} |