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

Support for alternate checkbox tasks

Open jwd-iv opened this issue 3 years ago • 32 comments

I've been using alternate checkboxes to track different task states, inspired by SlRvb's implementation in their ITS theme, and I've discovered that Dataview only recognizes checkboxes that have ' ', 'x', or 'X' in the box. Dataview ignores top-level checklist items that have any other character in the box, and nested alternate checklist items include "[char] " in their text.

Ideally, Dataview could recognize any bulleted item with any single character in the box at the front as a task. It would also be helpful to include that character as the task's state, status, type, or something along those lines.

Possible extensions:

  • Numerical tasks like - [2/10] Do this thing 10 times
  • Unicode glyphs (e.g. emoji)

jwd-iv avatar Jan 26 '22 02:01 jwd-iv

cc @eleanorkonik

AB1908 avatar Mar 05 '22 21:03 AB1908

I would love to retire this dataviewjs for what it's worth. https://gist.github.com/eleanorkonik/c650c193751436463f427690f680546e

eleanorkonik avatar Mar 05 '22 22:03 eleanorkonik

Will be available as task.status in the next major update.

blacksmithgu avatar Mar 06 '22 11:03 blacksmithgu

When is the next major update planned?

stoweboyd avatar Mar 22 '22 10:03 stoweboyd

@stoweboyd, it's in beta already! Go test it out!

AB1908 avatar Mar 22 '22 11:03 AB1908

It's currently available in beta (0.5.0) - you can use the Obsidian BRAT plugin to pick up beta releases.

blacksmithgu avatar Mar 22 '22 23:03 blacksmithgu

I tried it, and a bunch of my Taskidian queries broke. I'll wait until there is a detailed write-up.

And I tried task.status and that didn't work either. Maybe I am not configuring options correctly.

stoweboyd avatar Mar 23 '22 19:03 stoweboyd

In task queries it is just available as status (WHERE status = '<' for example).

Please share any broken task queries you have - the beta release is predominantly for me to catch breaking changes like queries not working.

blacksmithgu avatar Mar 24 '22 04:03 blacksmithgu

this query no longer works:

due today

TASK 
WHERE !completed 
WHERE (due = date(2022-03-26))
GROUP BY ø

Note: 'ø' is an attribute on in my task system, '- [ ] [ø:: !]' is an urgent task, for example. This will be replaced by '- [!]' when this evolution of dataview settles down.

due today

All my other 'due this week' type queries break in the same way

stoweboyd avatar Mar 26 '22 11:03 stoweboyd

I tried this query:

TASK FROM "00 workings"
WHERE !completed 
WHERE status = '!'

And got an error:

urgent

so the "status = '!'" doesn't seem to work. Likewise when trying as a string "!".

stoweboyd avatar Mar 26 '22 11:03 stoweboyd

The checkbox character doesn't look like it's being picked up ATM.

AB1908 avatar Mar 26 '22 12:03 AB1908

Use double quotes and not single quotes for strings - WHERE status = "!".

blacksmithgu avatar Mar 27 '22 07:03 blacksmithgu

I tried with double quotes (again). No worko.

Screen Shot 2022-03-27 at 4 47 32 PM Screen Shot 2022-03-27 at 4 47 41 PM

And still getting the 'maximum call stack size exceeded', too.

stoweboyd avatar Mar 27 '22 20:03 stoweboyd

@stoweboyd The reason your query is not working is because you are filtering on completed - completed is true as long as the status is not empty, to mimic Obsidian default rendering behavior, so a task marked '!' is considered completed. Just get rid of that check:

TASK FROM "00 workings"
WHERE status = "!"

blacksmithgu avatar Apr 02 '22 21:04 blacksmithgu

I can consider changing the semantics of completed while still in beta to only be true if the task status is 'x' or 'X'; I'm not sure if that would break any existing behavior. Possibly not.

Also, do you have some dummy example tasks that show the broken "stack call exceeded error"? I've fumbled with some basic GROUP BY task queries but been unable to break it.

blacksmithgu avatar Apr 02 '22 22:04 blacksmithgu

Re: !completed -- I will give that a try. It means I have to restructure queries, if I only want to see uncompleted tasks though, like '(status = "!") OR (status = "?") OR (status = "=")' and so on, for all non-completed task statuses.

Re: stack call error -- could be related to the number of tasks in my vault, right?

Here's one:


TASK
FROM "2022 journal" OR "00 work futures" OR "2021 journal" OR "00 other
projects"
WHERE (øø = "work futures") AND !completed AND (ø != ":")
GROUP BY ø

A typical Taskidian task is formed like '- [ ] [øø:: !] [øø:: work futures] some text'

Stowe

On Sat, Apr 2, 2022 at 6:03 PM blacksmithgu @.***> wrote:

I can consider changing the semantics of completed while still in beta to only be true if the task status is 'x' or 'X'; I'm not sure if that would break any existing behavior. Possibly not.

Also, do you have some dummy example tasks that show the broken "stack call exceeded error"? I've fumbled with some basic GROUP BY task queries but been unable to break it.

— Reply to this email directly, view it on GitHub https://github.com/blacksmithgu/obsidian-dataview/issues/812#issuecomment-1086731799, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXFR3UPSVASKEYWBHIXSSTVDC7ZZANCNFSM5MZ3AIEA . You are receiving this because you were mentioned.Message ID: @.***>

stoweboyd avatar Apr 06 '22 23:04 stoweboyd

I realized after thinking for a few minutes that '!completed' in your new approach should be equivalent to '(status != "x")'.

I reinstalled, and all my queries have the 'max call stack' error.

Here's one:

TASK
WHERE (status != "x")
WHERE (due = date(2022-04-07))
GROUP BY status

I get

Dataview: RangeError: Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded at ListItem$1.serialize (eval at (app://obsidian.md/app.js:1:1490278), :9799:14) at ListSerializationCache.get (eval at (app://obsidian.md/app.js:1:1490278), :9853:45) at eval (eval at (app://obsidian.md/app.js:1:1490278), :9801:53) at Array.map () at ListItem$1.serialize (eval at (app://obsidian.md/app.js:1:1490278), :9801:38) at ListSerializationCache.get (eval at (app://obsidian.md/app.js:1:1490278), :9853:45) at eval (eval at (app://obsidian.md/app.js:1:1490278), :9801:53) at Array.map () at ListItem$1.serialize (eval at (app://obsidian.md/app.js:1:1490278), :9801:38) at ListSerializationCache.get (eval at (app://obsidian.md/app.js:1:1490278), :9853:45)

Take care.

| Stowe

On Wed, Apr 6, 2022 at 7:20 PM Stowe Boyd @.***> wrote:

Re: !completed -- I will give that a try. It means I have to restructure queries, if I only want to see uncompleted tasks though, like '(status = "!") OR (status = "?") OR (status = "=")' and so on, for all non-completed task statuses.

Re: stack call error -- could be related to the number of tasks in my vault, right?

Here's one:


TASK
FROM "2022 journal" OR "00 work futures" OR "2021 journal" OR "00 other
projects"
WHERE (øø = "work futures") AND !completed AND (ø != ":")
GROUP BY ø

A typical Taskidian task is formed like '- [ ] [øø:: !] [øø:: work futures] some text'

Stowe

On Sat, Apr 2, 2022 at 6:03 PM blacksmithgu @.***> wrote:

I can consider changing the semantics of completed while still in beta to only be true if the task status is 'x' or 'X'; I'm not sure if that would break any existing behavior. Possibly not.

Also, do you have some dummy example tasks that show the broken "stack call exceeded error"? I've fumbled with some basic GROUP BY task queries but been unable to break it.

— Reply to this email directly, view it on GitHub https://github.com/blacksmithgu/obsidian-dataview/issues/812#issuecomment-1086731799, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXFR3UPSVASKEYWBHIXSSTVDC7ZZANCNFSM5MZ3AIEA . You are receiving this because you were mentioned.Message ID: @.***>

stoweboyd avatar Apr 07 '22 14:04 stoweboyd

This seems very odd and broken; the only way this call stack issue can happen is if the Obsidian metadata cache reports that a list element has a parent of itself or some other bad construction.

I've added an assertion to guard against this case, which may not fix the views but at least will give a more useful error. It's included in new release 0.5.8.

blacksmithgu avatar Apr 08 '22 08:04 blacksmithgu

For reference/comparison/assurance:

  • Task Collector doesn't fuss with default browser behavior of checked (has a value)
  • I do treat either x or X as completed. You can opt-in to also treating - as completed.
    • A recent ask was to suppress/remove X from this list, which I've done.
  • You can then specify values for "incomplete" items (as a simple string).
    • If you removed X from the above list, it is eligible to be included here instead.

Snippetor looks for these settings to help people set up custom/styled snippets:

  • https://github.com/ebullient/obsidian-snippetor/blob/b1346a636ada43bad5bc2098721aafcef33ce8a7/src/snippetor-Snippetor.ts#L29
  • https://github.com/ebullient/obsidian-snippetor/blob/b1346a636ada43bad5bc2098721aafcef33ce8a7/src/%40types/index.d.ts#L116

So I would suggest that dataview keep the HTML semantics of checked (has a non-empty value or not), and avoid crossing that with the meaning of "completed" (which we are all actively turning into something else). Specifically, this:

  • https://github.com/blacksmithgu/obsidian-dataview/blob/cea1c2acfc8745c208227706bd67d3a109a2cca9/src/ui/views/task-view.tsx#L64

ebullient avatar Apr 25 '22 18:04 ebullient

To get the Task Collector completion modal to work with dataview, I would need to override or augment what is happening here: https://github.com/blacksmithgu/obsidian-dataview/blob/cea1c2acfc8745c208227706bd67d3a109a2cca9/src/ui/views/task-view.tsx#L47

e.g. to allow dataview to open the task collector modal so someone could specify what value to mark the item with. Given this is a callback assigned directly on the item, I am a bit at a loss for how best to try to do anything else. I can intercept the click, but I don't then have the context to update the document with the character in a way that makes sense..

ebullient avatar Apr 25 '22 18:04 ebullient

I'll need to add an API option for overriding the click handler - that way Dataview can provide the task metadata and source file.

blacksmithgu avatar Apr 25 '22 20:04 blacksmithgu

that would be amazing!

ebullient avatar Apr 25 '22 20:04 ebullient

This will help with themes/snippets applying properly. The currently generated tasks don't have the information where snippets/themes expect it: https://github.com/blacksmithgu/obsidian-dataview/pull/1047

ebullient avatar Apr 26 '22 19:04 ebullient

This works (for using the task collector modal to get the status character): https://github.com/blacksmithgu/obsidian-dataview/pull/1048

ebullient avatar Apr 26 '22 20:04 ebullient

I am not sure if I should put the issue I have here, please let me know. So now "status" becomes an implicit field for dataview, I seem to not be able to filter my page level "status" field at Where clause anymore. Will there be a solution for this, or do I have to change my "status" field for something else for sure? I have a project with status:: [[active]] for example. On this project page, I have several tasks under two sections. In another note, I used dataview task to list those tasks:

from "folder" 
where contains(type, [[note]]) and contains(category,[[project]]) and contains(status, [[active]])
where contains(meta(section).subpath, "action items 1")
group by section
sort due asc

foenixp avatar May 26 '22 22:05 foenixp

Good point, I think you'd have to change the status field. A simple search and replace should suffice.

AB1908 avatar May 31 '22 18:05 AB1908

It all works! Thanks for your efforts.

Take care.

| Stowe

On Fri, Apr 8, 2022 at 3:51 PM Stowe Boyd @.***> wrote:

I'll give it a try over the weekend.

On Fri, Apr 8, 2022 at 4:03 AM blacksmithgu @.***> wrote:

This seems very odd and broken; the only way this call stack issue can happen is if the Obsidian metadata cache reports that a list element has a parent of itself or some other bad construction.

I've added an assertion to guard against this case, which may not fix the views but at least will give a more useful error. It's included in new release 0.5.8.

— Reply to this email directly, view it on GitHub https://github.com/blacksmithgu/obsidian-dataview/issues/812#issuecomment-1092569372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXFR3WYVSEDYF75TWUJMPLVD7R63ANCNFSM5MZ3AIEA . You are receiving this because you were mentioned.Message ID: @.***>

stoweboyd avatar Oct 11 '22 07:10 stoweboyd

I'll give it a try over the weekend.

On Fri, Apr 8, 2022 at 4:03 AM blacksmithgu @.***> wrote:

This seems very odd and broken; the only way this call stack issue can happen is if the Obsidian metadata cache reports that a list element has a parent of itself or some other bad construction.

I've added an assertion to guard against this case, which may not fix the views but at least will give a more useful error. It's included in new release 0.5.8.

— Reply to this email directly, view it on GitHub https://github.com/blacksmithgu/obsidian-dataview/issues/812#issuecomment-1092569372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXFR3WYVSEDYF75TWUJMPLVD7R63ANCNFSM5MZ3AIEA . You are receiving this because you were mentioned.Message ID: @.***>

stoweboyd avatar Oct 11 '22 08:10 stoweboyd

Let us know so we can close the issue.

AB1908 avatar Oct 11 '22 10:10 AB1908

I use this code to list the top notes with unchecked tasks, but it counts alternate checkboxes as non-completed. How can I make it also count alternat checkboxes as completed?

TABLE length(filter(file.tasks, (t) => !t.completed)) AS "Uncompleted" WHERE file.tasks AND length(file.tasks) > 0 AND length(filter(file.tasks, (t) => !t.completed)) > 0 SORT length(filter(file.tasks, (t) => !t.completed)) DESC

tiagobrc avatar Mar 23 '23 00:03 tiagobrc