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();