obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Show modified task name in dataview that’s still connected to original task

Open blacksmithgu opened this issue 2 years ago • 8 comments

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

blacksmithgu avatar Oct 03 '21 19:10 blacksmithgu

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?

max-mykhailenko avatar Nov 04 '21 16:11 max-mykhailenko

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.

blacksmithgu avatar Nov 06 '21 00:11 blacksmithgu

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()

sohanglal avatar Sep 26 '22 09:09 sohanglal

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?

AB1908 avatar Sep 26 '22 14:09 AB1908

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

sohanglal avatar Sep 26 '22 15:09 sohanglal

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.

AB1908 avatar Sep 26 '22 15:09 AB1908

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

sohanglal avatar Sep 26 '22 16:09 sohanglal

I have created a PR

sohanglal avatar Sep 28 '22 02:09 sohanglal