fix: load board detail with tasks on select, fix progress % calculation
All checks were successful
Build and Deploy DevOpsDash / build-image (push) Successful in 7s

- 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
This commit is contained in:
Henrik Jess Nielsen
2026-05-09 17:30:49 +02:00
parent 26e4bba041
commit d4cb06479c

View File

@@ -97,7 +97,7 @@
'bg-green-900/50 text-green-400': b.status==='active', 'bg-green-900/50 text-green-400': b.status==='active',
'bg-gray-800 text-gray-500': b.status==='completed'||b.status==='archived' '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)+'%'"></span> 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)+'%'"></span>
</div> </div>
</button> </button>
</template> </template>
@@ -471,6 +471,12 @@ document.addEventListener('alpine:init', () => {
}, },
async select(id) { async select(id) {
this.activeId = 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 */ }, openNewBoard() { /* TODO */ },
openNewTask(status) { /* TODO */ }, openNewTask(status) { /* TODO */ },
@@ -484,7 +490,7 @@ document.addEventListener('alpine:init', () => {
const idx = this.list.findIndex(b=>b.board_id===task.board_id); const idx = this.list.findIndex(b=>b.board_id===task.board_id);
if(idx>=0){ if(idx>=0){
const r=await fetch(`/api/v1/boards/${task.board_id}`).then(r=>r.json()); 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};
} }
} }
}); });