Export function for To Do

Hello TW-Friends,

I am using the To Do Plugin and it is working well.
But Due to the fact that I am not alone working with the wiki and I have to use the single file version I need to have the possibility to export the To Do s.
I found out the each To Do is made out of several Tiddlers and I am able to generate a list by using the right filter. But if I use the same filter for export it failed.

Here is my code:

title: To Do Overview

<$list filter="[all[shadows+tiddlers]removeprefix<td-basePath>removeprefix[/state/]sort[]]" variable=prj>
<hr>
<$macrocall $name=todolist-ui base=<<prj>> caption="""<h2 style="color:darkred;font-weight:lighter;"><$list filter="[field:created<prj>] - [<prj>]" />
<$set name=expFilter value="[prefix<td-basePath>suffix<prj>]">
<$button> export this ToDo
	<$action-sendmessage $message="tm-download-file" $param="$:/core/templates/exporters/JsonFile" exportFilter=<<expFilter>> filename="ToDo.json"/>
</$button>
</$set>
</h2>""" />
</$list>

If replace the <$button ....</$button> with <$list filter=<<expFilter>>/> the result ist correct.

e.g.:

$:/todolist/data/done/20230331160630623
$:/todolist/data/priority/20230331160630623
$:/todolist/data/state/20230331160630623
$:/todolist/data/status/20230331160630623
$:/todolist/data/tasks/20230331160630623

Any help is welcome
Stefan

The filter you are trying to apply is [prefix<td-basePath>suffix<prj>], which relies upon the current values of the td-basePath and prj variables. However, by the time the tm-download-file message is processed asynchronously by the TWCore saver module, the values of those variables are no longer “in scope” when the message is handled.

To make those variables available within the scope of the asynchronous processing, you need to explicitly pass them as extra parameters for the tm-download-file message, like this:

<$button> export this ToDo
	<$action-sendmessage $message="tm-download-file"
		$param="$:/core/templates/exporters/JsonFile"
		exportFilter=<<expFilter>> filename="ToDo.json"
		td-basePath=<<td-basePath>> prj=<<prj>>/>
</$button>

Alternatively, you could evaluate the filter to get the desired list of tiddlers before invoking the tm-download-file message and then pass that list of tiddlers to the message, like this:

<$set name=expFilter filter="[prefix<td-basePath>suffix<prj>]">
<$button> export this ToDo
	<$action-sendmessage $message="tm-download-file" $param="$:/core/templates/exporters/JsonFile" exportFilter=<<expFilter>> filename="ToDo.json"/>
</$button>
</$set>

Let me know how it goes…

-e

2 Likes

Hi @EricShulman ,

Thank you so much for the fast answer and support.

The second version is working fine, the first one is exporting something but not what is expected.

For documentation only here the final code I am using with some decoration for the button.

<$set name=expFilter filter="[prefix<td-basePath>suffix<prj>]">
<$button class="tc-btn-invisible tc-tiddlylink" tooltip="Export this Todo"> {{$:/core/images/export-button}}
<$action-sendmessage $message="tm-download-file" $param="$:/core/templates/exporters/JsonFile" exportFilter=<<expFilter>> filename="ToDo.json"/>
</$button>
</$set>

Stefan

Hi Stefan,
Once you know your filter, you could use the bundler plugin with a filtered-bundle.
The export would be a 1 or 2 click operation.

Since the bundler uses the same configuration as the $:/AdvancedSearch export configuration it should b e straight forward.

Just a thought.
-m

PS: Settings are in ControlPanel → Settings → WikiLabs → Bundler now

Hello all

I too have been trying to work out how to export data from the Todolist plugin. I identified the tiddlers I want to export by using the Advanced Search function as per the attached

But as I am not yet competent enough to work out the search filter I am not able to export the tiddlers as a batch.

Can someone help with the filter as I could not follow the code in the answers above.

@Mohammad The plugin is great but it would be even better if there was an export data facility within the plugin.

Cheers, Rob

Open $:/ControlPanel
Then navigate to Settings → Todolist Internals
You see all internal tiddlers keeping your Todos. All tiddlers are prefixed with $:/todolist/data/
So it is quite easy to export theme, or delete them

  • Open The $:/AdvancedSearch
  • In the filter tab enter [prefix[$:/todolist/data]] and then click export
  • That’s all

Step One: See what you have

Step Two: Export

1 Like

So simple !!

Many thanks @Mohammad. Much appreciated.

Rob

Hello @Rob_Jopling, @Mohammad,

I am using this as a very practicable solution for end users.
Here all To Do’s were listed and the user can individually delete the To Do and export them also individually for later import in different TW.

title: To Do Overview

<$list filter="[all[shadows+tiddlers]removeprefix<td-basePath>removeprefix[/state/]sort[]]" variable=prj>
<hr>
<$macrocall $name=todolist-ui base=<<prj>> caption="""<h2 style="color:darkred;font-weight:lighter;"><$list filter="[field:created<prj>] - [<prj>]" />
<$set name=bsFilter value="[prefix<td-basePath>suffix<prj>sort[]]">
<$button class="tc-btn-invisible tc-tiddlylink" tooltip="Delete this Todo?"> {{$:/core/images/delete-button}}
<$action-confirm $message="Do you really want to delete this Todo?">
 <$action-deletetiddler $filter=<<bsFilter>> />
</$action-confirm> 
</$button>
</$set>
<$set name=expFilter filter="[prefix<td-basePath>suffix<prj>]">
<$button class="tc-btn-invisible tc-tiddlylink" tooltip="Export this Todo"> {{$:/core/images/export-button}}
<$action-sendmessage $message="tm-download-file" $param="$:/core/templates/exporters/JsonFile" exportFilter=<<expFilter>> filename="ToDo.json"/>
</$button>
</$set>
</h2>""" />
</$list>

Together with this here on ther bottom of each tiddler with tag xyz the To Do is listed and a link to the overview will be shown.

tags: $:/tags/ViewTemplate
title: $:/todolist/todolist

<$list filter="[all[current]tag[xyz]]]">

<$transclude $variable="todolist-ui" caption="Manage your items to do here:" width="" base={{!!created}} />
<hr>
[[To Do Overview]]
</$list>

Perhaps my solution will serve as inspiration

Stefan