From 92eca626b74433502e6d2179702535d7afd21901 Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 13 Jul 2026 10:45:47 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20tags=20contextuels=20=E2=80=94=20couleur?= =?UTF-8?q?=20envoy=C3=A9e=20et=20stock=C3=A9e=20par=20l'API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend (dashboard.py): - POST /api/local-workspace/items//tags accepte maintenant 'color' - INSERT INTO tags (name, color) au lieu de INSERT INTO tags (name) - Si tag existe déjà, garde sa couleur existante Frontend (local_workspace.html): - ctxAddNewTag envoie {name, color} dans le body de la requête (avant: seul {name} était envoyé, la couleur était ignorée) --- app/routers/dashboard.py | 5 +++-- app/templates/local_workspace.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/routers/dashboard.py b/app/routers/dashboard.py index a097925..f518452 100644 --- a/app/routers/dashboard.py +++ b/app/routers/dashboard.py @@ -1281,6 +1281,7 @@ async def add_item_tag(request: Request, item_id: int): import json body = await request.json() tag_name = body.get("name", "").strip().lower() + tag_color = body.get("color", "#787774") if not tag_name: return {"error": "Tag name required"}, 400 @@ -1289,11 +1290,11 @@ async def add_item_tag(request: Request, item_id: int): tag = conn.execute("SELECT id, name, color FROM tags WHERE name = ?", (tag_name,)).fetchone() if not tag: cursor = conn.execute( - "INSERT INTO tags (name) VALUES (?)", (tag_name,) + "INSERT INTO tags (name, color) VALUES (?, ?)", (tag_name, tag_color) ) conn.commit() tag_id = cursor.lastrowid - tag = {"id": tag_id, "name": tag_name, "color": "#787774"} + tag = {"id": tag_id, "name": tag_name, "color": tag_color} else: tag_id = tag["id"] diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html index f6dd1de..6040225 100644 --- a/app/templates/local_workspace.html +++ b/app/templates/local_workspace.html @@ -861,7 +861,7 @@ window._wsInitData = (function() { color = color || this.ctxNewTagColor; var r = await fetch('/api/local-workspace/items/' + node.id + '/tags', { method: 'POST', headers: {'Content-Type':'application/json'}, - body: JSON.stringify({name: tagName.trim()}) + body: JSON.stringify({name: tagName.trim(), color: color}) }); if (r.ok) { var d = await r.json();