Recursively traversing stream-list

I am working on a modified row-body for streams that will show a counter of how many incomplete TODO items exist underneath, for the sake of my being able to collapse and expand lists on complex projects without out-of-sight-out-of-mind problems:

I have made a pretty good start – however, I’d like to run the counter recursively down the stream-list, so that in the above example, the “Maintenance” counter would show (4), by adopting the “Normalize Naming Schemas” count in addition to its own.

<$list filter="[enlist{!!stream-list}tag[TODO]!tag[done]count[]!match[0]]">
        <div class="todo-counter">
            <$count filter="[enlist{!!stream-list}tag[TODO]!tag[done]]"/>
        </div>
    </$list>

Is this something I should be looking at a plugin for help with, or am I missing some obvious filter solution?

Try something along these lines:

[<currentTiddler>get-stream-nodes[]tag[TODO]!tag[done]count[]]

<$list filter="[<currentTiddler>get-stream-nodes[]tag[TODO]!tag[done]count[]!match[0]]">
    <div class="todo-counter">
        <$count filter="[<currentTiddler>get-stream-nodes[]tag[TODO]!tag[done]]"/>
    </div>
</$list>

Renders counters of 0 for all tiddlers matching TODO+!done, even with !match[0]

That is surprising. Does using this filter in a node correctly report all its descendants?

[<currentTiddler>get-stream-nodes[]]

Are you using any Streams addons that might be modifying the behaviour of the filter?

PS: the code you posted overwrites the currentTiddler variable in the first list widget, set the list widget variable to a different name such as totalTasks.

<$list filter="[<currentTiddler>get-stream-nodes[]tag[TODO]!tag[done]count[]!match[0]]" variable="totalTasks">
    <div class="todo-counter">
        <$text text="totalTasks"/>
    </div>
</$list>

oh, you know I am :wink:

Ah, trial/error in a node body rather than modifying the template each time is a fantastic idea - - you’re onto something, the following does seem to work:

<$list filter="[<currentTiddler>get-stream-nodes[]tag[TODO]!tag[done]count[]!match[0]]" variable="totalTasks">
    <div class="todo-counter">
        <<totalTasks>>
    </div>
</$list>

<style>
.stream-node-block {
    position: relative;
}

.todo-counter {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff3333;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}
</style>

Now I’ve got it working I’ll attempt to incorporate it into the template next I sit at the PC and report back :slight_smile: Thanks @saqimtiaz!

Got it! :slight_smile: What eventually worked:

 <div class="stream-node-block">
  <$list filter="[<currentTiddler>get-stream-nodes[]tag[TODO]!tag[done]!<currentTiddler>count[]!match[0]]" variable="totalTasks">
    <div class="todo-counter">
        <$text text=<<totalTasks>>/>
    </div>
</$list>

I was having some confusing trouble earlier, but it seems to have gotten sorted after I’d taken some time away – maybe just morning brain fog :smiley:

2 Likes