Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set completion when modifying tasks #448

Closed
sheeley opened this issue Aug 25, 2021 · 14 comments
Closed

Set completion when modifying tasks #448

sheeley opened this issue Aug 25, 2021 · 14 comments
Projects

Comments

@sheeley
Copy link
Contributor

sheeley commented Aug 25, 2021

When clicking a task's checkbox to complete it, mark it as completed and add a completion date.

The opposite should happen when marking a task as not done.

@sheeley sheeley created this issue from a note in Tasks (To do) Aug 25, 2021
@sheeley
Copy link
Contributor Author

sheeley commented Sep 6, 2021

@blacksmithgu It looks like

export async function setTaskCheckedInFile(
should handle this already - am I misreading what it does?

@blacksmithgu
Copy link
Owner

It does mark it a completed; it just doesn't add the completion date.

@sheeley
Copy link
Contributor Author

sheeley commented Sep 6, 2021

Got it! I was uncertain about the base implementation, I wonder if I've found a bug I can reproduce. Will keep exploring.

@sheeley sheeley moved this from To do to In progress in Tasks Oct 9, 2021
@sheeley sheeley changed the title Support modifying tasks via task view Set completion when modifying tasks Oct 9, 2021
@kngautham
Copy link

kngautham commented Oct 18, 2021

Adding the Completion date to each Task will be nice. Will this happen in the near future? Thank you very much.

@sheeley
Copy link
Contributor Author

sheeley commented Oct 18, 2021

@kngautham potentially! I have some time off coming soon, and this is partially implemented in a branch.

@blacksmithgu Any thoughts or guidance on an API like hasAnnotation(str, "completion") and setAnnotation(str, "completion", "2021-01-01")?

@blacksmithgu
Copy link
Owner

We can implement mutating calls (and tasks are easier than for general inline fields), though we need to be a little careful - they don't fit very well into "repeatedly refreshing DataviewJS views". We'd need to add support for adding buttons or something to gate them behind, or also potentially implement one-off script execution.

@sheeley
Copy link
Contributor Author

sheeley commented Oct 19, 2021

Totally - I was expecting this to be additive to the existing checking-the-box behavior. Do you have a way to identify the location of annotations within text already?

@kngautham
Copy link

Thank you very much, I will wait

@blacksmithgu
Copy link
Owner

Yes, the inline field code tracks the position of all task annotations, so it should be as simple as a text replace.

sheeley added a commit that referenced this issue Oct 23, 2021
sheeley added a commit that referenced this issue Oct 23, 2021
Sets/removes completion inline annotation on tasks when being checked
Adds support for tasks in *-based lists
sheeley added a commit that referenced this issue Oct 23, 2021
Sets/removes completion inline annotation on tasks when being checked
Adds support for tasks in *-based lists
blacksmithgu pushed a commit that referenced this issue Oct 28, 2021
Sets/removes completion inline annotation on tasks when being checked
Adds support for tasks in *-based lists
@sheeley sheeley moved this from In progress to Done in Tasks Oct 29, 2021
@midas0441
Copy link

Cool! I came here to file this exact feature-request and it appears to have been already done.

Question: in settings, can a user specify keyword for completed? For example, done. This request is related to my post here regarding user flexibility.

Thanks for a great plugin!

@sheeley
Copy link
Contributor Author

sheeley commented Nov 2, 2021

I also use the key done rather than completed, so this is configurable. It'll be included in the next release of dataview, I believe.

@blacksmithgu
Copy link
Owner

Implemented and merged to master thanks to @sheeley!

@dmnkf
Copy link

dmnkf commented Nov 27, 2021

Can someone give me an example of how I can use the completion date in dataviewjs?

I would like to List all completed tasks of the day.

@sheeley
Copy link
Contributor Author

sheeley commented Nov 27, 2021

This is my daily view, I use done rather than completion:

let curr = dv.current()
let today = curr.file.day.toISODate()

// TODAY'S TASKS ==============================
let tasks = dv.pages().where(p => {
	return !p.ignoreTasks &&
		p.file != curr.file
})
	.file.tasks
	.where(t => {
		if (t.due && today == t.due.toISODate()) {
			return true
		}
		if (t.done && today == t.done.toISODate()) {
			return true
		}
	})
	.sort(t => t.completed, 'asc')

if (tasks.length) {
	dv.header(2, "Tasks")
	dv.taskList(tasks, false)
}

// CREATED/UPDATED TODAY
let todayPages = dv.pages().where(p => {
	return p.file.name != curr.file.name &&
		(p.file.ctime.toISODate() == today || p.file.mtime.toISODate() == today)
})
	.sort(p => p.file.mtime, 'desc').file.link

if (todayPages.length > 0) {
	dv.header(2, "Today's Notes")
	dv.list(todayPages)
}

// CURRENT GOALS ==============================
let goals = dv.page("Current Goals").file.tasks
	.sort(t => t.completed, 'asc')
if (goals.length) {
	dv.header(2, "[[Current Goals]]")
	dv.taskList(goals, false)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Tasks
Done
Development

No branches or pull requests

5 participants