Completed items view.

This commit is contained in:
Chris McCormick 2025-12-30 18:28:31 +08:00
parent d7be502e0a
commit 1c6aa158c2
2 changed files with 59 additions and 6 deletions

View file

@ -16,6 +16,8 @@
- [x] Give each column a max width of 450px and have them stretch to fill the area up to that. - [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 ## In progress

View file

@ -104,6 +104,12 @@
flex-shrink: 0; flex-shrink: 0;
} }
.header-controls {
display: flex;
gap: 0.5em;
align-items: center;
}
.board { .board {
display: flex; display: flex;
gap: 1em; gap: 1em;
@ -253,7 +259,10 @@
<div id="board-screen" class="screen"> <div id="board-screen" class="screen">
<header> <header>
<h2 id="board-title" style="margin:0">Project Name</h2> <h2 id="board-title" style="margin:0">Project Name</h2>
<button id="back-btn">Back to Projects</button> <div class="header-controls">
<button id="toggle-completed-btn">Show Completed</button>
<button id="back-btn">Back to Projects</button>
</div>
</header> </header>
<div id="board-container" class="board"></div> <div id="board-container" class="board"></div>
</div> </div>
@ -270,7 +279,8 @@
filePath: null, filePath: null,
sections: [], // Parsed data sections: [], // Parsed data
currentSectionIndex: -1, currentSectionIndex: -1,
lastModified: 0 lastModified: 0,
showCompleted: false
}; };
// --- IndexedDB Helper --- // --- IndexedDB Helper ---
@ -427,6 +437,10 @@
if (!section) return renderSectionPicker(); if (!section) return renderSectionPicker();
document.getElementById('board-title').textContent = section.name; 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'); const container = document.getElementById('board-container');
container.innerHTML = ''; container.innerHTML = '';
@ -448,6 +462,10 @@
cardList.className = 'card-list'; cardList.className = 'card-list';
column.cards.forEach((card, cardIndex) => { column.cards.forEach((card, cardIndex) => {
if (!state.showCompleted && card.completed) {
return;
}
const cardDiv = document.createElement('div'); const cardDiv = document.createElement('div');
cardDiv.className = `card ${card.completed ? 'completed' : ''}`; cardDiv.className = `card ${card.completed ? 'completed' : ''}`;
cardDiv.textContent = card.text; cardDiv.textContent = card.text;
@ -477,7 +495,10 @@
// Persist selection // Persist selection
if (state.filePath) { if (state.filePath) {
const key = `kbtd:${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)); localStorage.setItem(key, JSON.stringify(uiState));
} }
renderBoard(); renderBoard();
@ -491,6 +512,25 @@
renderBoard(); 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 --- // --- Drag and Drop ---
let dragSource = null; // { colIndex, cardIndex } let dragSource = null; // { colIndex, cardIndex }
@ -554,14 +594,21 @@
state.sections = parseMarkdown(text); state.sections = parseMarkdown(text);
// Restore UI state // Restore UI state
if (state.currentSectionIndex === -1 && state.filePath) { if (state.filePath) {
const key = `kbtd:${state.filePath}`; const key = `kbtd:${state.filePath}`;
const stored = localStorage.getItem(key); const stored = localStorage.getItem(key);
if (stored) { if (stored) {
try { try {
const uiState = JSON.parse(stored); 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); } } catch (e) { console.error(e); }
} }
} }
@ -718,6 +765,10 @@
renderSectionPicker(); renderSectionPicker();
}; };
document.getElementById('toggle-completed-btn').onclick = () => {
toggleShowCompleted();
};
document.getElementById('change-file-btn').onclick = () => { document.getElementById('change-file-btn').onclick = () => {
// To change file, we basically want to pick a new one. // To change file, we basically want to pick a new one.
// If we are in the app, we might want to clear state. // If we are in the app, we might want to clear state.