Ability to delete a card.
This commit is contained in:
parent
9b0c5f332b
commit
e69faff782
2 changed files with 33 additions and 2 deletions
2
TODO.md
2
TODO.md
|
|
@ -9,13 +9,13 @@
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- [ ] Warning colored note on home and about page if browser doesn't support FileSystem Access API.
|
- [ ] Warning colored note on home and about page if browser doesn't support FileSystem Access API.
|
||||||
- [ ] Ability to delete an item, with confirmation.
|
|
||||||
- [ ] Display sub-lines of the form `key: value` immediately after item
|
- [ ] Display sub-lines of the form `key: value` immediately after item
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
|
- [x] Ability to delete an item, with confirmation.
|
||||||
- [x] When the dots menu shows on a 'completed' item the stuff behind it shows through
|
- [x] When the dots menu shows on a 'completed' item the stuff behind it shows through
|
||||||
- [x] Pressing + in a column and then cancel removes the button entirely
|
- [x] Pressing + in a column and then cancel removes the button entirely
|
||||||
- [x] Group all indented lines after each item with the item
|
- [x] Group all indented lines after each item with the item
|
||||||
|
|
|
||||||
33
index.html
33
index.html
|
|
@ -1338,6 +1338,24 @@ chmod 755 kbtd
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteCard(lineNumber) {
|
||||||
|
console.log('deleteCard:', lineNumber);
|
||||||
|
await modifyFileLines(lines => {
|
||||||
|
const cardInfo = findCardByLineNumber(lineNumber);
|
||||||
|
if (!cardInfo) {
|
||||||
|
console.error('Could not find card with line number', lineNumber);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const card = cardInfo.card;
|
||||||
|
const nestedLineCount = card.nestedLines.length;
|
||||||
|
|
||||||
|
lines.splice(lineNumber, 1 + nestedLineCount);
|
||||||
|
|
||||||
|
console.log('Deleted card at line', lineNumber, 'with', nestedLineCount, 'nested lines');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function moveLineInFile(fromLine, toLine, targetColumnIndex, insertPosition) {
|
async function moveLineInFile(fromLine, toLine, targetColumnIndex, insertPosition) {
|
||||||
console.log('moveLineInFile: from line', fromLine, 'to line', toLine, 'targetColumnIndex:', targetColumnIndex, 'insertPosition:', insertPosition);
|
console.log('moveLineInFile: from line', fromLine, 'to line', toLine, 'targetColumnIndex:', targetColumnIndex, 'insertPosition:', insertPosition);
|
||||||
await modifyFileLines(lines => {
|
await modifyFileLines(lines => {
|
||||||
|
|
@ -1941,9 +1959,22 @@ chmod 755 kbtd
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const deleteItem = h('button', {
|
||||||
|
className: 'card-menu-item',
|
||||||
|
textContent: 'Delete',
|
||||||
|
onclick: async (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
closeAllCardMenus();
|
||||||
|
if (confirm('Are you sure you want to delete this card?')) {
|
||||||
|
const lineNum = getDataInt(cardDiv, 'lineNumber');
|
||||||
|
await deleteCard(lineNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const menu = h('div', {
|
const menu = h('div', {
|
||||||
className: 'card-menu'
|
className: 'card-menu'
|
||||||
}, completeItem, moveItem);
|
}, completeItem, moveItem, deleteItem);
|
||||||
|
|
||||||
cardDiv.append(cardHeader, menu);
|
cardDiv.append(cardHeader, menu);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue