Show completed subtasks.

This commit is contained in:
Chris McCormick 2026-01-04 16:12:41 +08:00
parent 22bb934bb3
commit ceaedb6435

View file

@ -305,6 +305,7 @@
.card-footer { .card-footer {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end;
font-size: 0.85em; font-size: 0.85em;
color: var(--shade); color: var(--shade);
} }
@ -1141,6 +1142,23 @@ chmod 755 kbtd
}); });
} }
function countSubtasks(nestedLines) {
let total = 0;
let completed = 0;
for (const line of nestedLines) {
const trimmed = line.trim();
if (trimmed.startsWith('- [ ]')) {
total++;
} else if (trimmed.startsWith('- [x]')) {
total++;
completed++;
}
}
return { total, completed };
}
function parseMarkdown(text) { function parseMarkdown(text) {
const lines = text.split('\n'); const lines = text.split('\n');
const sections = []; const sections = [];
@ -1821,6 +1839,7 @@ chmod 755 kbtd
if (!state.showCompleted && card.completed) return; if (!state.showCompleted && card.completed) return;
const hasNestedContent = card.nestedLines.length > 0; const hasNestedContent = card.nestedLines.length > 0;
const subtasks = countSubtasks(card.nestedLines);
const cardDiv = h('div', { const cardDiv = h('div', {
className: `card ${card.completed ? 'completed' : ''}`, className: `card ${card.completed ? 'completed' : ''}`,
@ -1905,10 +1924,20 @@ chmod 755 kbtd
if (hasNestedContent) { if (hasNestedContent) {
const cardFooter = h('div', { className: 'card-footer' }); const cardFooter = h('div', { className: 'card-footer' });
const expandIndicator = h('span', { let expandIndicator;
className: 'card-expand-indicator',
textContent: '+' if (subtasks.total > 0) {
}); expandIndicator = h('span', {
className: 'card-expand-indicator',
textContent: `${subtasks.completed}/${subtasks.total}`
});
} else {
expandIndicator = h('span', {
className: 'card-expand-indicator',
textContent: '+'
});
}
cardFooter.append(expandIndicator); cardFooter.append(expandIndicator);
cardDiv.append(cardFooter); cardDiv.append(cardFooter);
} }