Searching for Flexible Checkboxes for Task Management

Everything in TW is built from tiddlers. It’s tiddlers all the way down. There is no shame in using tiddlers to build a checklist. A solution based on parsing the text of a tiddler is going to be a bit fragile or limited. Tags are the most natural way to build hierarchical structures – like sublists.

So pull a couple definitions out of the toc macros and roll your own. Tag with $:/tags/Macro:

\define toc-body-checkbox(tag,sort:"",itemClassFilter,exclude,path)
\whitespace trim
<ol class="tc-toc">
  <$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]""">
    <$let item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
      <$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]">
        <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
          <li class=<<toc-item-class>>>
            <$list filter="[all[current]toc-link[no]]" emptyMessage="<$checkbox tag='done'/>&nbsp;<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}><<toc-caption>></$link>">
              <<toc-caption>>
            </$list>
            <$macrocall $name="toc-body-checkbox" tag=<<item>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<excluded>> path=<<path>>/>
          </li>
        </$set>
      </$set>
    </$let>
  </$list>
</ol>
\end


\define toc-checkbox(tag,sort:"",itemClassFilter:"", exclude)
\whitespace trim
<$let __tag__={{{ [<__tag__>is[blank]then<currentTiddler>else<__tag__>] }}} >
  <$macrocall $name="toc-body-checkbox"  tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>>/>
</$let>
\end

That looks like a lot of code, but I actually only changed a few places.

Invoke like

<div class="tc-table-of-contents">
<<toc-checkbox "Contents" >>

</div>

And, voila! – you have your checklist with subtasks:

image

(There’s anomalies because of the nature of the data).

But if you want completed tasks to disappear, you can also invoke like:

<div class="tc-table-of-contents">
<<toc-checkbox "Contents" exclude:"[tag[done]]">>

</div>
2 Likes

I like that. :slight_smile:

2 Likes

Hello everyone.

I haven’t really made much progress on this topic, but by chance today I had the intuition to try something to get closer to having subtasks using the $__plugins_tw-FRed_tw5-checklist, and the result isn’t bad.

This is the text I put in the tiddler:

[ ] Garden tasks

<<<
[ ] Dig
[x] Cover holes in the wall where the mice come out
<<<
[x] Shed tasks

<<<
[x] Clean the car
[x] Organize the tools
<<<

And this is what I get.

1

I’m sure playing with CSS can hide the gray bar, and that would be ideal. If the bar is in the way, of course…

Maybe it’ll be useful for someone.

Best regards.

Hi @JuanPalomo
in case you haven’t tried, this can also be done with @hoopyfrood wiki by just adding ^ to items
Drag this Example Tiddler.json (248 Bytes) onto the wiki.

Hi Sunny.

Yes, I’ve seen that. I’ll have to look at the code to see if I can adapt it. The more alternatives we have, the easier it will be to find the one that best fits our projects.

Best regards.

I like the TOC approach, and made a minor adjustment in case anyone else wants to use it.

Below is a modification that allows you to choose the checked tag that is applied. I don’t think there are any issues with what I’ve added. For the time being, I’m going to experiment with adding the ability to choose multiple tags upon being checked or showing a specific field over the title, just haven’t quite figured that out yet lol

\define toc-body-checkbox(tag,sort:"",itemClassFilter,exclude,path)
\whitespace trim
<ol class="tc-toc">
  <$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]""">
    <$let item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
      <$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]">
        <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
          <li class=<<toc-item-class>>>
            <$list filter="[all[current]toc-link[no]]" emptyMessage="<$checkbox tag={{{[<__checked__>]}}}/>&nbsp;<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}><<toc-caption>></$link>">
              <<toc-caption>>
            </$list>
            <$macrocall $name="toc-body-checkbox" tag=<<item>> checked=<<checked>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<excluded>> path=<<path>>/>
          </li>
        </$set>
      </$set>
    </$let>
  </$list>
</ol>
\end

\define toc-checkbox(tag,checked:"done",sort:"",itemClassFilter:"", exclude)
\whitespace trim
<$let __tag__={{{ [<__tag__>is[blank]then<currentTiddler>else<__tag__>] }}} >
  <$macrocall $name="toc-body-checkbox"  tag=<<__tag__>> checked=<<__checked__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>>/>
</$let>
\end
<div class="tc-table-of-contents">
<<toc-checkbox "Tasks" exclude:"[tag[Done]]" checked:"Done">>

</div>

Find the toc-caption macro in the core tiddlers and copy it into your working macros. Change the name to toc-field (or whatever) and then change the reference to <<toc-caption>> in the toc-body-checkbox macro to <<toc-field>> . Make appropriate changes toc-field to use your preferred field.

ohh, so I thought it was there but I couldn’t get it to work and figured I was misreqding it, turns out I misspelled caption when setting which field :sweat_smile: heh, oops.

This is quite nice for “in tiddler todo lists”.

I wonder if using [ ] [ ] etc could be used to indicate nesting. Or perhaps a similar looking Unicode character. I already have an editor toolbar button to add remove [ ] from selected lines in a tiddler. Similarly I modified the autolist plugin so <enter> on a line with some wikitext indicators, continues the prefix on the next line.

  • A way to add items like with $:/plugins/tgrosinger/tw5-checklist

Since this example hoopy-wiki allows one to delete items, a small improvment may be the ability to click to excise to a tiddler with templated tag/fields.

  • I imagin it would use the current tiddler as a tag, so we could also list such excised to do items, perhaps replacing them with a macro link, and determining the status from the tiddler.
1 Like