From d4cb06479cb2b3b2734422dffd215ee71dc4df1d Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Sat, 9 May 2026 17:30:49 +0200 Subject: [PATCH] fix: load board detail with tasks on select, fix progress % calculation - select() now fetches /api/v1/boards/{id} to get tasks array (lazy, once) - updateTaskStatus() merges response correctly (spread instead of replacing) - Progress % in sidebar uses done_count/task_count from list summary, or computed from tasks array when board detail is loaded --- app/templates/dashboard.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 8fcd4fa..bc63cfc 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -97,7 +97,7 @@ 'bg-green-900/50 text-green-400': b.status==='active', 'bg-gray-800 text-gray-500': b.status==='completed'||b.status==='archived' }" - x-text="Math.round(((b.tasks||[]).filter(t=>t.status==='done').length/Math.max(1,(b.tasks||[]).length))*100)+'%'"> + x-text="Math.round((b.tasks ? b.tasks.filter(t=>t.status==='done').length/Math.max(1,b.tasks.length) : (b.done_count||0)/Math.max(1,b.task_count||1))*100)+'%'"> @@ -471,6 +471,12 @@ document.addEventListener('alpine:init', () => { }, async select(id) { this.activeId = id; + // fetch full board detail (includes tasks array) if not yet loaded + const idx = this.list.findIndex(b=>b.board_id===id); + if(idx>=0 && !this.list[idx].tasks) { + const r = await fetch(`/api/v1/boards/${id}`).then(r=>r.json()); + this.list[idx] = {...this.list[idx], ...r}; + } }, openNewBoard() { /* TODO */ }, openNewTask(status) { /* TODO */ }, @@ -484,7 +490,7 @@ document.addEventListener('alpine:init', () => { const idx = this.list.findIndex(b=>b.board_id===task.board_id); if(idx>=0){ const r=await fetch(`/api/v1/boards/${task.board_id}`).then(r=>r.json()); - this.list[idx]=r.board; + this.list[idx]={...this.list[idx], ...r}; } } });