From 74fe8aed64c0ccbe5e0d3acf1cb2a2c7d0c123d6 Mon Sep 17 00:00:00 2001 From: bruno Date: Wed, 8 Jul 2026 11:42:05 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20feedback=20visuel=20imm=C3=A9diat=20apr?= =?UTF-8?q?=C3=A8s=20drag-and-drop=20+=20correction=20r=C3=A9solution=20ID?= =?UTF-8?q?s=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /api/move retourne maintenant les labels mis à jour - Le frontend met à jour les labels de la carte sans recharger la page - Flash vert sur la carte pour confirmer le succès du déplacement - Correction: résolution noms→IDs des labels via l'API Gitea (update_issue_labels attend des ints) - Mise à jour de data-column sur la carte déplacée --- app/routers/api.py | 16 ++++++++++++---- app/templates/board.html | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/routers/api.py b/app/routers/api.py index 91ddc69..31fbb6c 100644 --- a/app/routers/api.py +++ b/app/routers/api.py @@ -139,6 +139,7 @@ async def move_card( conn.commit() + labels = [] if mapping: try: if mapping["close_issue"]: @@ -147,13 +148,20 @@ async def move_card( issue = await gitea.get_issue(owner, repo, issue_id) current_labels = [lbl["name"] for lbl in issue.get("labels", [])] status_labels = await _get_status_labels(owner, repo, board_id) - filtered = [l for l in current_labels if l not in status_labels] - filtered.append(mapping["gitea_label"]) - await gitea.update_issue_labels(owner, repo, issue_id, filtered) + filtered_names = [l for l in current_labels if l not in status_labels] + filtered_names.append(mapping["gitea_label"]) + + # Resolve label names to IDs + all_labels = await gitea.get_labels(owner, repo) + name_to_id = {lbl["name"]: lbl["id"] for lbl in all_labels} + label_ids = [name_to_id[n] for n in filtered_names if n in name_to_id] + + result = await gitea.update_issue_labels(owner, repo, issue_id, label_ids) + labels = [{"name": lbl["name"], "color": lbl.get("color", "666")} for lbl in result] except Exception as e: logger.warning("Gitea sync failed: %s", e) - return {"status": "ok", "issue_id": issue_id, "column": column} + return {"status": "ok", "issue_id": issue_id, "column": column, "labels": labels} async def _get_status_labels(owner: str, repo: str, board_id: int) -> list[str]: diff --git a/app/templates/board.html b/app/templates/board.html index 9706b4a..93a36a3 100644 --- a/app/templates/board.html +++ b/app/templates/board.html @@ -237,6 +237,25 @@ method: 'POST', headers: {'X-CSRF-Token': getCSRFToken()} }); if (!resp.ok) throw new Error('Move failed'); + const data = await resp.json(); + + // Update card's data-column + card.dataset.column = newCol; + + // Update labels on the moved card + const labelsDiv = card.querySelector('.card-labels'); + if (labelsDiv && data.labels) { + labelsDiv.innerHTML = data.labels.map(l => + `${escHtml(l.name)}` + ).join(''); + } + + // Flash feedback + card.style.transition = 'box-shadow 0.3s'; + card.style.boxShadow = '0 0 0 2px var(--green)'; + setTimeout(() => { card.style.boxShadow = ''; }, 800); + + // Update column counts document.querySelectorAll('.board-column').forEach(col => { const c = col.querySelectorAll('.card').length; const b = col.querySelector('.column-count');