From 8497a36da98c9354fc5deceeb52cdac3f2b90c53 Mon Sep 17 00:00:00 2001 From: bruno Date: Sat, 11 Jul 2026 14:00:57 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20bouton=20delete=20cass=C3=A9=20+=20previ?= =?UTF-8?q?ew=20PDF=20cliquable=20+=20ic=C3=B4nes=20distinctes=20FlowDeck?= =?UTF-8?q?=20vs=20upload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Delete: ev.target pouvait รชtre un noeud texte (emoji ๐Ÿ—‘) โ†’ Text.closest() n'existe pas โ†’ handleTreeAction รฉchouait. Fix: fallback sur ev.target.parentElement.closest(). 2. Preview PDF: ajout lien 'Open viewer โ†’' vers /pages/{id} (le viewer standalone rend le PDF dans une iframe). 3. Icรดnes distinctes: - Pages FlowDeck (content_format='blocks'/'markdown') โ†’ ๐Ÿ“ - Fichiers uploadรฉs โ†’ icรดne basรฉe sur l'extension - _fileIcon() accepte contentFormat, propage depuis l'API tree - Appliquรฉ dans sidebar (board.py) + page workspace (x-for + renderChildren) --- app/routers/board.py | 13 ++++++++----- app/templates/local_workspace.html | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/routers/board.py b/app/routers/board.py index ccfe352..f039572 100644 --- a/app/routers/board.py +++ b/app/routers/board.py @@ -140,9 +140,12 @@ def _build_page_tree(conn, parent_id: int | None, ws_key: str, depth: int = 0, m return items -def _file_icon(name: str) -> str: +def _file_icon(name: str, content_format: str = "") -> str: """Map file extension to emoji icon.""" import re + # FlowDeck internal pages (no extension) + if content_format and content_format != 'file': + return '๐Ÿ“' n = name.lower() if re.search(r'\.(png|jpe?g|gif|webp|svg|bmp|ico)$', n): return '๐Ÿ–ผ๏ธ' if n.endswith('.pdf'): return '๐Ÿ“•' @@ -169,7 +172,7 @@ def _load_workspace_pages(ws_cookie: str) -> list: ws_id = int(ws_cookie) with get_conn() as conn: rows = conn.execute( - "SELECT id, title, parent_section FROM pages WHERE workspace_id=? AND parent_id IS NULL ORDER BY created_at DESC", + "SELECT id, title, parent_section, content_format FROM pages WHERE workspace_id=? AND parent_id IS NULL ORDER BY created_at DESC", (ws_id,), ).fetchall() items = [] @@ -179,7 +182,7 @@ def _load_workspace_pages(ws_cookie: str) -> list: items.append({ "db_id": r["id"], "name": title, "id": f"page/{r['id']}", - "icon": "๐Ÿ“" if is_folder else _file_icon(title), + "icon": "๐Ÿ“" if is_folder else _file_icon(title, r["content_format"]), "is_folder": is_folder, "children": _load_children(r["id"]), }) @@ -192,7 +195,7 @@ def _load_children(parent_id: int) -> list: """Recursively load children of a page.""" with get_conn() as conn: rows = conn.execute( - "SELECT id, title, parent_section FROM pages WHERE parent_id=? ORDER BY created_at", + "SELECT id, title, parent_section, content_format FROM pages WHERE parent_id=? ORDER BY created_at", (parent_id,), ).fetchall() children = [] @@ -202,7 +205,7 @@ def _load_children(parent_id: int) -> list: children.append({ "db_id": r["id"], "name": title, "id": f"page/{r['id']}", - "icon": "๐Ÿ“" if is_folder else _file_icon(title), + "icon": "๐Ÿ“" if is_folder else _file_icon(title, r["content_format"]), "is_folder": is_folder, "children": _load_children(r["id"]), }) diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html index 628c07a..6e57e52 100644 --- a/app/templates/local_workspace.html +++ b/app/templates/local_workspace.html @@ -207,7 +207,7 @@ - +