From 7d62aa02be71b7c003a2a2d8bc133748290860c3 Mon Sep 17 00:00:00 2001 From: perco Date: Tue, 19 May 2026 17:30:12 +0200 Subject: [PATCH] =?UTF-8?q?fix(planka):=20position=20obligatoire=20pour=20?= =?UTF-8?q?d=C3=A9placer=20une=20carte=20+=20filtre=20listes=20None?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - dropCard envoie position (max+65535) car Planka l'exige pour changer listId - Ajout vérification res.ok + toast d'erreur/succès - Filtre les listes avec name='None' (placeholders Planka sans nom) Co-Authored-By: Claude Sonnet 4.6 --- modules/planka/api.php | 5 +++-- planka.php | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/planka/api.php b/modules/planka/api.php index b83b993..b5d58a1 100644 --- a/modules/planka/api.php +++ b/modules/planka/api.php @@ -69,9 +69,10 @@ if ($action === 'board') { $resp = planka_api('GET', '/api/boards/' . $id, null, $token); $inc = $resp['included'] ?? []; - // Filter lists that actually belong to this board (prevents ghost lists from other boards) + // Filter: only lists with a real name (Planka creates unnamed "None" placeholder lists) $lists = array_values(array_filter($inc['lists'] ?? [], fn($l) => - isset($l['boardId']) ? $l['boardId'] === $id : true + !empty($l['name']) && $l['name'] !== 'None' && + (isset($l['boardId']) ? $l['boardId'] === $id : true) )); // Filter cards that belong to a list in this board $listIds = array_column($lists, 'id'); diff --git a/planka.php b/planka.php index 55fb509..6b9e6d0 100644 --- a/planka.php +++ b/planka.php @@ -205,9 +205,16 @@ async function dropCard(listId) { if (!dragCardId) return; const card = state.cards.find(c => c.id === dragCardId); if (!card || card.listId === listId) return; - await apiFetch('update_card', { id: dragCardId }, 'PATCH', { listId }); + // Planka requires position when changing listId + const targetCards = state.cards.filter(c => c.listId === listId); + const maxPos = targetCards.reduce((m, c) => Math.max(m, c.position || 0), 0); + const position = maxPos + 65535; + const res = await apiFetch('update_card', { id: dragCardId }, 'PATCH', { listId, position }); + if (!res.ok) { showToast('Erreur déplacement : ' + (res.error || 'inconnu'), 'error'); return; } card.listId = listId; + card.position = position; renderBoard(); + showToast('Carte déplacée'); } async function quickAddCard(listId) {