I use a couple of plugins:
- The DataTiddlerPlugin, which lets you store structured data on your tiddlers.
- The ForEachTiddler plugin, which lets you generate customised lists of tiddlers.
One thing I had been struggling with was to come up with a way to have conditional formatting on the tables. The idea is to change the colour based on the priority of the ToDo item, or whether the target date is in the past or not.
I have posted an example in TiddlySpot. You can find it on the followuplist TiddlyWiki.
Here is the script I used for the tiddler:
- <<forEachTiddler
- where
- 'tiddler.tags.contains("FollowUp")
&& tiddler.tags.contains("Name") &&
!tiddler.data("Completed") == true &&
!tiddler.tags.contains("TiddlerTemplates")' sortBy 'tiddler.data("Priority")' - script
- '
- // date format DD/MM/YYYY
- function dateDifference(tiddler) {
- var d1, d2;
- var s = tiddler.data("TargetDate");
- if (s == undefined) { return 0 }
- d1 = new Date();
- d2 = new Date();
- d2.setMonth(s.substr(3,2)-1);
- d2.setDate(s.substr(0,2));
- d2.setFullYear(s.substr(6,4));
- return d2-d1;
- }
- function writeRow(index, tiddler)
- { var result = ""; if (index == 0) {result = "|!Priority|!Description|!Date Opened|!Target Date|\n";}
- if (tiddler.data("Priority") == 1) {result += "|bgcolor(orange):"}
- else if (tiddler.data("Priority") == 2) {result += "|bgcolor(yellow):"}
- else if (tiddler.data("Priority") == 3) {result += "|bgcolor(lightgreen):"}
- else {result += "|"}
- // result += dateDifference(tiddler) + "|";
- result += tiddler.data("Priority") + "|[[" + tiddler.title + "]]|" + tiddler.data("DateOpened") + "|" ;
- if (dateDifference(tiddler) < 0 ) {
- result += "bgcolor(orange):";
- } else if (dateDifference(tiddler) == 0 ) {
- result += "bgcolor(yellow):";
- }
- result += tiddler.data("TargetDate") + "|\n";
- return result;
- }
- '
- write
- 'writeRow(index, tiddler)'
- >>
No comments:
Post a Comment