obsidian-dataview
obsidian-dataview copied to clipboard
Show modified task name in dataview that’s still connected to original task
Discussed in https://github.com/blacksmithgu/obsidian-dataview/discussions/521
Originally posted by DeutscheGabanna October 3, 2021
Let’s suppose I have this task.
- [ ] a task [unnecessary filler]
and I want to query it and show it, slightly modified through regex, to look like this
found 1 task:
- [ ] a task
You can quite easily modify the string with this snippet:
for (let i = 0; i < source.length; i++) {
source[i].text = source[i].text.replace("a", "b");
and then display it:
dv.taskList(source, false);
However, the task that is displayed has no connection to the original task whatsoever! As long as its displayed name differs in any way, the original task doesn't change its state if you check/uncheck its clone from dataview.
Please help
Is it possible to have unlink task complete status from the original task, but another parts left as is. Case I have some common reading list. I have multiple students and want to interview each student about this reading list. I don't want to copy each time common reading list for each student, I want to have snippet like
dv.taskList(dv.page("Onboarding reading list").file.tasks.map(b => {b.text = b.text.replace(" "," "); return b}))
// this is special replace off all spaces to another utf space for unlinking from the original list
And if I add or change something in common list it automatically should be added to each student.
How it possible to do? Any thoughts?
That use case is a little complicated for current task list support - checking and unchecking kind of requires a 1:1 correspondence between a task in an actual file somewhere, and the Dataview view of it.
This will probably get better in the future, though I don't think it's supported right now.
A workaround to this problem is to store tasks.text
to an array before making any modifications to it
Data from the array can be restored after running dv.taskList()
I think this has been fixed recently. Dataview now has a task.visual
that is used to display text if it exists, and this does not (at least, it isn't supposed to) break the task's checkbox toggle thingy. Can you try in the latest version and report back?
Thanks a lot! task.visual
is working flawlessly.
On a side note, I went throught the documentation but wasn't able to find task.visual
Ah yes, this wasn't added to the docs I think. Would you mind pushing a PR for it? If not, I'll take care of it in #1433.
I haven't pushed a PR before but would would love to give it a shot! Will read about it and push in a few days
I have created a PR