fix(board): l'indice « Glissez une carte ici » suit enfin le contenu des colonnes

Rendu par le serveur pour les colonnes vides au chargement, il
n'était jamais retiré après un dépôt (signalé par Bruno). Nouvelle
fonction refreshEmptyHints() appelée après chaque déplacement et
après chaque retour arrière: indice retiré si la colonne contient
une carte, rétabli si elle devient vide. SortableJS restreint aux
cartes (draggable: '.kanban-card'). Logique vérifiée par mini-test
DOM (4 scénarios) en plus de node --check.
This commit is contained in:
Spark
2026-10-11 12:08:28 -04:00
parent 52c41ead91
commit 542ed70c1a
+22
View File
@@ -28,12 +28,14 @@ document.addEventListener('DOMContentLoaded', () => {
new Sortable(col, {
group: 'kanban',
animation: 200,
draggable: '.kanban-card',
ghostClass: 'dragging',
onStart: function () { window.__kanbanteDragging = true; },
dragClass: 'dragging',
onEnd: function (evt) {
window.__kanbanteDragging = false;
if (evt.from === evt.to && evt.oldIndex === evt.newIndex) return;
refreshEmptyHints();
const card = evt.item;
const formData = new FormData();
formData.append('repo_full_name', card.dataset.repo);
@@ -69,6 +71,7 @@ document.addEventListener('DOMContentLoaded', () => {
.catch(err => {
console.error('Move failed:', err);
revert(evt);
refreshEmptyHints();
showToast('❌ Échec du déplacement — carte replacée', true);
});
}
@@ -115,6 +118,25 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
// The "Glissez une carte ici" hint is rendered by the server only
// for columns empty at page load. After a drag, the DOM is the
// truth: remove the hint from columns that hold cards, restore it
// on columns that became empty. (Bug reported 2026-10-11: the
// hint stayed forever after dropping a card into an empty column.)
function refreshEmptyHints() {
document.querySelectorAll('.column-cards').forEach(list => {
const hint = list.querySelector('.column-empty');
const hasCards = !!list.querySelector('.kanban-card');
if (hasCards && hint) hint.remove();
if (!hasCards && !hint) {
const p = document.createElement('p');
p.className = 'column-empty';
p.textContent = 'Glissez une carte ici';
list.appendChild(p);
}
});
}
function updateCounts() {
document.querySelectorAll('.kanban-column').forEach(col => {
const count = col.querySelectorAll('.kanban-card').length;