Batch complete tasks

name

Batch tasks

icon

done_all

instructions


1. Open the note options menu and select one of the available actions
2. You can choose to complete all of the tasks in the current note OR all of the tasks in one or more of the tags currently applied to the note. If you select multiple tags, tasks will be removed from notes that have ALL of the selected tags (and not or).


{
noteOption: {
async "Batch complete all tasks in this note" (app, noteUUID) {
const result = await app.prompt(
"WARNING\nThis operation cannot be undone (except manually). Are you sure you want to proceed with marking tasks in this note as complete?",
{
inputs: [
{
options: [
{label: "Proceed", value: "Proceed"},
{label: "Go back", value: "Go back"},
],
type: "radio"
}
]
}
);
console.log(result);
if (result !== "Proceed") return;
 
const tasks = await app.getNoteTasks({uuid: noteUUID});
for (const task of tasks) {
await app.updateTask(task.uuid, {completedAt: Math.floor(Date.now() / 1000)});
}
},
 
async "Batch complete all tasks in this note's tag" (app, noteUUID) {
const result = await app.prompt(
"WARNING\nThis operation cannot be undone (except manually). Are you sure you want to proceed with marking tasks as complete?",
{
inputs: [
{
options: [
{label: "Proceed", value: "Proceed"},
{label: "Go back", value: "Go back"},
],
type: "radio"
}
]
}
);
console.log(result);
if (result !== "Proceed") return;
 
const thisNote = await app.findNote({uuid: noteUUID});
const tags = thisNote.tags;
const tagsToComplete = await app.prompt(
"Choose the tag in which you want to mark tasks as complete:",
{
inputs: tags.map(tag => (
{type: "checkbox", label: tag, value: tag}
))
}
);
console.log(tagsToComplete);
let tagList = [];
 
for (let i = 0; i < tags.length; i++) {
if(tagsToComplete[i]) tagList.push(tags[i]);
}
if (!tagList) return;
 
console.log(tagList.join(","));
const notes = await app.filterNotes({tag: tagList.join(",")});
console.log(notes);
 
for (const note of notes) {
const tasks = await app.getNoteTasks({uuid: note.uuid});
for (const task of tasks) {
await app.updateTask(task.uuid, {completedAt: Math.floor(Date.now() / 1000)});
}
}
}
}
}