SID-00311: Summarizing status of ChildTodoTopics in ParentTodoTopic
|
|
| Status: |
Answered |
TWiki version: |
4.2.2 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
|
Last update: |
10 month ago |
|
|
|
I have a parent topic with some child "TodoList" topics, each child with a handful of todo items in them. (the parent/child relationship is secondary to this question; it is simply organizational)
Individual line items in the todo lists have either %ICON{unchecked}% or %ICON{checked}% somewhere within them, indicating whether they've been completed or not. I'd like to be able to have the parent topic show the "status" of the child for each child. For example:
- TodoList %IF{ (...TodoList contains %ICON{unchecked}%) then="still has open items" else="are all done" }%
What I've not been able to figure out is how to implement the test -
the (...TodoList contains %ICON{unchecked}%) part. Per
IfStatements the special operators for IF do not include
anything to support this. So, Per recommendation of Peter Thoeny I'm working out how to wrap an IF around a SEARCH to make this work. The first step of this solution would be to have the search return either "unchecked" (if any unchecked items are in the topic) or an empty string if no unchecked items were found. Once that works, I can wrap an IF similar to the one above around the result, to emit the then or else clause instead of "unchecked" or empty-string. At least, that's the strategy right now.
Here's the "raw view" of a simple todo list:
- %ICON{checked}% Create this simple todo list
- %ICON{unchecked}% Make a dynamic todo list status summarizer
Here's the "raw view" of a searcher for that todo list:
%SEARCH{"TodoList" type="regex" scope="topic" topic="TodoList" nonoise="on" nosearch="on" nototal="on" format="$pattern(.*%ICON{(unchecked)}%).*"}%
The hope was that this woud emit either "unchecked" (if there were any unchecked items) or an empty string if none were found. HOWEVER, instead it emits the VERY odd following result:
$pattern(.*<img width=
So, thinking quotes are part of the problem I replaced the double-quotes around the format= parameter value with $quot - that helped SOME but doesn't do the trick either. This second search looks like this:
%SEARCH{"TodoList" type="regex" scope="topic" topic="TodoList" nonoise="on" nosearch="on" nototal="on" format=$quot$pattern(.*%ICON{(unchecked)}%).*$quot}%
And it emits a one-line TABLE naming the topic, creation date, and author - i.e. (not exactly but similar to...)
TodoList [new] 12 May 2009 - 22:38
PaulReiber
So this is progress (I guess) but it's now ignoring the format string, it seems.
I'm at wit's end; any help, insight, recommendations, or just plain commiseration would be very much appreciated.
--
PaulReiber - 2009-05-12
I've recreated the above here on TWiki.org in the sandbox - please see (and feel free to experiment with):
SuperSimpleTodoList and
SuperSimpleTodoListSummarizer
--
PaulReiber - 2009-05-12
Try this:
format="$pattern(.*[%]ICON{(unchecked)}[%].*)"
--
PeterThoeny - 2009-05-12
Wow that did the trick. I've left
SuperSimpleTodoListSummarizer in the Sandbox web for others to review w.r.t. what worked and what didn't.
I had accidentally omitted the closing parens for the $pattern(...) - amongst other things.
Thanks, Peter, for your help with these magic TWiki incantations!
I'll update that same Sandbox topic with an additional incantation including an IF wrapper once that works.
Thanks again and best regards,
-Paul
--
PaulReiber - 2009-05-13
You can try to do the conditional inside the format with an escaped CALC. Untested example:
format="$percntCALC{$IF($EXACT($pattern(.*[%]ICON{(unchecked)}[%].*),), are all done, still has open items)}$percnt"
Details at
FormattedSearch,
SpreadSheetPlugin
--
PeterThoeny - 2009-05-13
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.