svg
This commit is contained in:
@ -98,6 +98,17 @@
|
||||
</content>
|
||||
</main>
|
||||
|
||||
<div class="toast-container position-fixed top-0 end-0 p-3" style="z-index: 9999;">
|
||||
<div id="ajaxErrorToast" class="toast align-items-center text-bg-danger border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body" id="ajaxErrorMessage">
|
||||
Une erreur est survenue.
|
||||
</div>
|
||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Fermer"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="mymodal" class="modal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
|
@ -417,26 +417,15 @@
|
||||
},
|
||||
|
||||
update: function (event, ui) {
|
||||
// ❗ Se déclenche même pour tri dans la même colonne
|
||||
if (!event.originalEvent) return; // ← ignorer les appels indirects
|
||||
console.log("UPDATE");
|
||||
if (!event.originalEvent) return;
|
||||
const $targetContainer = $(this);
|
||||
|
||||
const sourceId = $sourceContainer.data('id');
|
||||
const targetId = $targetContainer.data('id');
|
||||
|
||||
// Ne pas dupliquer l'appel si c’est un vrai "receive"
|
||||
if (ui.sender) return;
|
||||
|
||||
sendUpdate(sourceId, targetId, $sourceContainer, $targetContainer, $movedItem, originalIndex);
|
||||
},
|
||||
|
||||
receive: function (event, ui) {
|
||||
const $targetContainer = $(this);
|
||||
const sourceId = $sourceContainer.data('id');
|
||||
const targetId = $targetContainer.data('id');
|
||||
|
||||
sendUpdate(sourceId, targetId, $sourceContainer, $targetContainer, $movedItem, originalIndex);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function sendUpdate(sourceId, targetId, $sourceContainer, $targetContainer, $movedItem, originalIndex) {
|
||||
@ -455,17 +444,14 @@
|
||||
url: url,
|
||||
method: 'POST',
|
||||
data: {
|
||||
source: sourceId,
|
||||
target: targetId,
|
||||
sourceIssues: sourceIssues,
|
||||
targetIssues: targetIssues
|
||||
},
|
||||
success: function (response) {
|
||||
console.log('Déplacement réussi', response);
|
||||
},
|
||||
error: function (xhr) {
|
||||
console.error('Erreur AJAX', xhr);
|
||||
|
||||
console.log(xhr);
|
||||
// Annuler le déplacement
|
||||
if ($movedItem && $sourceContainer) {
|
||||
const items = $sourceContainer.children();
|
||||
@ -475,6 +461,14 @@
|
||||
$movedItem.insertBefore(items.eq(originalIndex));
|
||||
}
|
||||
}
|
||||
|
||||
const message = xhr.responseJSON?.message || 'Une erreur est survenue lors de la requête.';
|
||||
$('#ajaxErrorMessage').text(message);
|
||||
|
||||
const toast = new bootstrap.Toast(document.getElementById('ajaxErrorToast'), {
|
||||
delay: 5000
|
||||
});
|
||||
toast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user