Check a box to add today's date to a custom field?

41 views
Skip to first unread message

cmari

unread,
Sep 14, 2008, 9:53:08 PM9/14/08
to TiddlyWiki
I want to store, display, and sort by a date that will "stick" to a
tiddler even if it is subsequently modified (e.g., to stamp the
completion date of a project).

My current approach (though I'm willing to be pointed toward a better
one!) has been to add a "datestamp" in YYYY/0MM/0DD format in a custom
field, since that lets me easily sort and/or display both tiddlers and
their completion dates in a table or list. (One very cool additional
bonus I just discovered today is that it's possible to build on
TiddlerSortMethods in MonkeyGTD, so that an mgtdList can also be
sorted by "completion" date).

Right now, using Eric's very helpful ListboxPlugin, I'm adding the
completion date by way of a macro in the tiddler that says:
<<select completed rows:1 {{(new Date()).formatString('YYYY/0MM/
0DD')}} >>
(I'm probably not using this the right way because, for any date other
than today's, the display field includes the text "other: ").

What I'd like is to be able to accomplish this by simply ticking a box
- I'm envisioning something like what CheckboxPlugin can do, but with
a date as the result, instead of "true". It seems to me this ought to
be possible (and further down the road I see possibilities for adding
this to a ViewTemplate, and maybe even associating it directly with
toggling the "Done" tag). But I'm not clever enough to figure out
how. Or maybe this is really obvious and someone has already done
it? Any suggestions would be greatly appreciated!
cmari

lewcid

unread,
Sep 15, 2008, 4:51:38 AM9/15/08
to TiddlyWiki
Hmm.. I just wrote a small plugin for myself that might do the trick
for you:
http://svn.tiddlywiki.org/Trunk/contributors/SaqImtiaz/verticals/POLS250/instructorsnotebook/plugins/toggleFieldPlugin.js

Put this in your tiddler/ViewTemplate/toolbar:
<<toggleField datestamp {{(new Date).formatString("YYYY/0MM/0DD")}}
datestamp>>

Saq

Eric Shulman

unread,
Sep 15, 2008, 6:01:32 AM9/15/08
to TiddlyWiki
> What I'd like is to be able to accomplish this by simply ticking a box
> - I'm envisioning something like what CheckboxPlugin can do, but with
> a date as the result, instead of "true". It seems to me this ought to
> be possible (and further down the road I see possibilities for adding
> this to a ViewTemplate, and maybe even associating it directly with
> toggling the "Done" tag). But I'm not clever enough to figure out
> how. Or maybe this is really obvious and someone has already done
> it? Any suggestions would be greatly appreciated!

You can do all of this today with CheckboxPlugin! In your
ViewTemplate, you can write:

<span macro="checkbox done [[]] [[]] [[]]

[[{store.setValue(story.findContainingTiddler(place).getAttribute('tiddler'),'completed',new
Date().formatString('YYYY/0MM/0DD'))}]] "></span>

In addition to adding/removing the 'done' tag from the current
tiddler, the checkbox also triggers an onAfterClick handler that sets
the value in the 'completed' field of the containing tiddler equal to
the current date, just as you requested.

The macro parameters in the example above are as follows:

"done" - the name of the desired target tag, stored with the current
tiddler. Setting the checkbox will add the "done" tag to the
tiddler. Clearing the checkbox removes the tag from the tiddler.

[[]] [[]] [[]] - three blank 'placeholder' parameters:
* ID for config.options.chk* (blank=value will not be saved to
config.options.*)
* onInit handler - (blank=standard checkbox initialization)
* onBeforeClick handler - (blank=standard checkbox click handling
occurs)

[[{store.setValue(...)}]] - defines the onAfterClick handler that is
triggered *after* the checkbox has performed its normal handling, so
that side-effect processing can be invoked in response to changes in
the checkbox state.

That should do it... let me know if you run into any snags...

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

http://www.TiddlyTools.com/#CheckboxPlugin
http://www.TiddlyTools.com/#CheckboxPluginInfo

cmari

unread,
Sep 18, 2008, 9:10:32 PM9/18/08
to TiddlyWiki
A belated thank you for the two different options that were provided
so quickly - I have already deployed both of them. It was especially
helpful to see a specific example of the way to use the onAfterclick
handler in the CheckboxPlugin - thanks!
cmari
Reply all
Reply to author
Forward
0 new messages