Ability to complete item in detail view.
This commit is contained in:
parent
99c0429d1a
commit
02d4a17c12
1 changed files with 29 additions and 5 deletions
34
index.html
34
index.html
|
|
@ -1071,6 +1071,8 @@ chmod 755 kbtd
|
||||||
card: null,
|
card: null,
|
||||||
originalTitle: '',
|
originalTitle: '',
|
||||||
originalContent: '',
|
originalContent: '',
|
||||||
|
originalCompleted: false,
|
||||||
|
isCompleted: false,
|
||||||
baseIndent: ''
|
baseIndent: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1476,13 +1478,13 @@ chmod 755 kbtd
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateCardInFile(lineNumber, newTitle, newNestedContent, baseIndent) {
|
async function updateCardInFile(lineNumber, newTitle, newNestedContent, baseIndent, isCompleted) {
|
||||||
console.log('updateCardInFile:', lineNumber, newTitle, newNestedContent, baseIndent);
|
console.log('updateCardInFile:', lineNumber, newTitle, newNestedContent, baseIndent, isCompleted);
|
||||||
await modifyCard(lineNumber, (lines, cardInfo) => {
|
await modifyCard(lineNumber, (lines, cardInfo) => {
|
||||||
const card = cardInfo.card;
|
const card = cardInfo.card;
|
||||||
const oldNestedLineCount = card.nestedLines.length;
|
const oldNestedLineCount = card.nestedLines.length;
|
||||||
|
|
||||||
const checkbox = card.completed ? '[x]' : '[ ]';
|
const checkbox = isCompleted ? '[x]' : '[ ]';
|
||||||
const newCardLine = `- ${checkbox} ${newTitle}`;
|
const newCardLine = `- ${checkbox} ${newTitle}`;
|
||||||
|
|
||||||
const newNestedLines = applyBaseIndent(newNestedContent, baseIndent);
|
const newNestedLines = applyBaseIndent(newNestedContent, baseIndent);
|
||||||
|
|
@ -1942,6 +1944,8 @@ chmod 755 kbtd
|
||||||
card: card,
|
card: card,
|
||||||
originalTitle: card.text,
|
originalTitle: card.text,
|
||||||
originalContent: strippedContent,
|
originalContent: strippedContent,
|
||||||
|
originalCompleted: card.completed,
|
||||||
|
isCompleted: card.completed,
|
||||||
baseIndent: baseIndent
|
baseIndent: baseIndent
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1955,6 +1959,8 @@ chmod 755 kbtd
|
||||||
card: null,
|
card: null,
|
||||||
originalTitle: '',
|
originalTitle: '',
|
||||||
originalContent: '',
|
originalContent: '',
|
||||||
|
originalCompleted: false,
|
||||||
|
isCompleted: false,
|
||||||
baseIndent: ''
|
baseIndent: ''
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -1966,10 +1972,26 @@ chmod 755 kbtd
|
||||||
|
|
||||||
const titleChanged = titleInput.value !== cardDetailModalState.originalTitle;
|
const titleChanged = titleInput.value !== cardDetailModalState.originalTitle;
|
||||||
const contentChanged = contentTextarea.value !== cardDetailModalState.originalContent;
|
const contentChanged = contentTextarea.value !== cardDetailModalState.originalContent;
|
||||||
const isModified = titleChanged || contentChanged;
|
const completedChanged = cardDetailModalState.isCompleted !== cardDetailModalState.originalCompleted;
|
||||||
|
const isModified = titleChanged || contentChanged || completedChanged;
|
||||||
|
|
||||||
|
const completedCheckbox = h('div', {
|
||||||
|
className: `card-menu-checkbox ${cardDetailModalState.isCompleted ? 'checked' : ''}`
|
||||||
|
});
|
||||||
|
|
||||||
|
const completedBtn = h('button', {
|
||||||
|
id: 'card-detail-completed-btn',
|
||||||
|
style: { display: 'flex', alignItems: 'center', gap: '0.5em', marginRight: 'auto',
|
||||||
|
background: 'transparent', color: 'var(--fg)', border: '.1rem solid var(--fg)' },
|
||||||
|
onclick: () => {
|
||||||
|
cardDetailModalState.isCompleted = !cardDetailModalState.isCompleted;
|
||||||
|
updateCardDetailButtons();
|
||||||
|
}
|
||||||
|
}, completedCheckbox, h('span', { textContent: 'Completed' }));
|
||||||
|
|
||||||
if (isModified) {
|
if (isModified) {
|
||||||
buttonsContainer.replaceChildren(
|
buttonsContainer.replaceChildren(
|
||||||
|
completedBtn,
|
||||||
h('button', {
|
h('button', {
|
||||||
id: 'card-detail-cancel-btn',
|
id: 'card-detail-cancel-btn',
|
||||||
textContent: 'Cancel',
|
textContent: 'Cancel',
|
||||||
|
|
@ -1983,6 +2005,7 @@ chmod 755 kbtd
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
buttonsContainer.replaceChildren(
|
buttonsContainer.replaceChildren(
|
||||||
|
completedBtn,
|
||||||
h('button', {
|
h('button', {
|
||||||
id: 'card-detail-close-btn',
|
id: 'card-detail-close-btn',
|
||||||
textContent: 'Close',
|
textContent: 'Close',
|
||||||
|
|
@ -2008,7 +2031,8 @@ chmod 755 kbtd
|
||||||
cardDetailModalState.card.lineNumber,
|
cardDetailModalState.card.lineNumber,
|
||||||
newTitle,
|
newTitle,
|
||||||
newContent,
|
newContent,
|
||||||
cardDetailModalState.baseIndent
|
cardDetailModalState.baseIndent,
|
||||||
|
cardDetailModalState.isCompleted
|
||||||
);
|
);
|
||||||
|
|
||||||
cardDetailModal.close();
|
cardDetailModal.close();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue