Toggling text when clicking a link

I have a macro that inserts the following code in a new tiddler to create a to-do item for me:

<$checkbox tag="done" /> [[TODO]] Buy milk

Whenever I click the “TODO” link, I want it to change to “WAITING”, and then go back to “TODO” if I click it again. This is similar in functionality to Logseq.

Each tiddler will never have more than one to-do item, because I am using streams.

I’m not sure where to start. Ideally it would be a global macro so that it doesn’t change the code needed to create a to-do item (<$checkbox tag="done" /> [[TODO]] Buy milk). Does anyone have any ideas? I appreciate the help.

I’m getting close. I created a macro to toggle the links:

\define toggleTodo() 
    <$action-listops $field="todo" $subfilter="+[toggle[TODO],[WAITING]]" />
\end

My template for the TODO button is:

<$button class="tc-btn-invisible tc-tiddlylink" actions=<<toggleTodo>>>

 {{ !!todo }}

</$button> 

And my new template for to-do items is:

<$checkbox tag="done" /> {{||$:/bp1189/templates/todoLink}} test

Now I just need to figure out how to create a default “todo” field in new streams.

EDIT: Got it. Just created a new template tiddler and added it to the Streams settings.

Hope this helps someone.

\o/ - I love it that you found your own solutions and also shared it. – Well done

It would be even nicer, if you would create a little testcase, which contains all your templates and 3 “content” tiddlers, so other users could play with your solution :wink:

3 Likes

Thanks!

I would love to share it when I get some time to clean it all up. In the meantime, for anyone interested, I took a lot of concepts from GitHub - rr-tw5/rr-tw5.github.io: A Roam Research Styled TiddlyWiki.

2 Likes