fix: bouton delete cassé + preview PDF cliquable + icônes distinctes FlowDeck vs upload
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)
This commit is contained in:
@@ -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"]),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user