Action

Modify Tasks

Posted by agiletortoise, Last update about 1 year ago - Unlisted

Ask for operation to perform on all tasks in the editor. Options:

  • Reset: Restore all tasks to original state
  • Complete: Mark all tasks complete
  • Advance: Move all tasks to their next possible state. For simple on-off tasks, this will just toggle all.

Steps

  • script

    let f = () => {
    	// prompt for operation
    	let p = new Prompt()
    	p.title = "Modify Tasks"
    	p.message = "Adjust all tasks in the editor..."
    	p.addSelect("op", "Operation", ["Mark Complete", "Reset", "Advance"], ["Mark Complete"])
    	p.addButton("OK")
    
    	if(!p.show()) {
    		return false
    	}
       //get tasks and loop over them
    	let tasks = editor.tasks.reverse()
    	switch(p.fieldValues["op"][0]) {
    		case "Mark Complete":
    			for (const task of tasks) {
    				editor.completeTask(task)
    			}
    			break
    		case "Reset":
    			for (const task of tasks) {
    				editor.resetTask(task)
    			}
    			break
    		case "Advance":
    			for (const task of tasks) {
    				editor.advanceTask(task)
    			}
    			break
    		default: return false
    	}
    	return true
    }
    
    if(!f()) {
    	context.cancel()
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.