From 1c6aa158c2a8d7bda6bedcf9359cf343b3ba83e9 Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Tue, 30 Dec 2025 18:28:31 +0800 Subject: [PATCH] Completed items view. --- TODO.md | 2 ++ index.html | 63 ++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index e7ef59a..ece97a5 100644 --- a/TODO.md +++ b/TODO.md @@ -16,6 +16,8 @@ - [x] Give each column a max width of 450px and have them stretch to fill the area up to that. +- [ ] Secific check type of UI for marking items complete/uncomplete. + ## In progress diff --git a/index.html b/index.html index 15c43df..bcda3f3 100644 --- a/index.html +++ b/index.html @@ -104,6 +104,12 @@ flex-shrink: 0; } + .header-controls { + display: flex; + gap: 0.5em; + align-items: center; + } + .board { display: flex; gap: 1em; @@ -253,7 +259,10 @@

Project Name

- +
+ + +
@@ -270,7 +279,8 @@ filePath: null, sections: [], // Parsed data currentSectionIndex: -1, - lastModified: 0 + lastModified: 0, + showCompleted: false }; // --- IndexedDB Helper --- @@ -427,6 +437,10 @@ if (!section) return renderSectionPicker(); document.getElementById('board-title').textContent = section.name; + + const toggleBtn = document.getElementById('toggle-completed-btn'); + toggleBtn.textContent = state.showCompleted ? 'Hide Completed' : 'Show Completed'; + const container = document.getElementById('board-container'); container.innerHTML = ''; @@ -448,6 +462,10 @@ cardList.className = 'card-list'; column.cards.forEach((card, cardIndex) => { + if (!state.showCompleted && card.completed) { + return; + } + const cardDiv = document.createElement('div'); cardDiv.className = `card ${card.completed ? 'completed' : ''}`; cardDiv.textContent = card.text; @@ -477,7 +495,10 @@ // Persist selection if (state.filePath) { const key = `kbtd:${state.filePath}`; - const uiState = { currentSection: state.sections[index].name }; + const uiState = { + currentSection: state.sections[index].name, + showCompleted: state.showCompleted + }; localStorage.setItem(key, JSON.stringify(uiState)); } renderBoard(); @@ -491,6 +512,25 @@ renderBoard(); } + function toggleShowCompleted() { + state.showCompleted = !state.showCompleted; + + if (state.filePath) { + const key = `kbtd:${state.filePath}`; + const stored = localStorage.getItem(key); + let uiState = {}; + if (stored) { + try { + uiState = JSON.parse(stored); + } catch (e) { console.error(e); } + } + uiState.showCompleted = state.showCompleted; + localStorage.setItem(key, JSON.stringify(uiState)); + } + + renderBoard(); + } + // --- Drag and Drop --- let dragSource = null; // { colIndex, cardIndex } @@ -554,14 +594,21 @@ state.sections = parseMarkdown(text); // Restore UI state - if (state.currentSectionIndex === -1 && state.filePath) { + if (state.filePath) { const key = `kbtd:${state.filePath}`; const stored = localStorage.getItem(key); if (stored) { try { const uiState = JSON.parse(stored); - const idx = state.sections.findIndex(s => s.name === uiState.currentSection); - if (idx !== -1) state.currentSectionIndex = idx; + + if (state.currentSectionIndex === -1) { + const idx = state.sections.findIndex(s => s.name === uiState.currentSection); + if (idx !== -1) state.currentSectionIndex = idx; + } + + if (uiState.showCompleted !== undefined) { + state.showCompleted = uiState.showCompleted; + } } catch (e) { console.error(e); } } } @@ -718,6 +765,10 @@ renderSectionPicker(); }; + document.getElementById('toggle-completed-btn').onclick = () => { + toggleShowCompleted(); + }; + document.getElementById('change-file-btn').onclick = () => { // To change file, we basically want to pick a new one. // If we are in the app, we might want to clear state.