A Modular Action Mechanism For Tiddler Save Button

This may be discussed elsewhere, but I cannot find the discussion.

There are requests to do some actions on tiddler save like:

  1. convert a field value like date field to TW date format, e.g user enters 2022-08-25 and on save it needs to be converted into 20220825120000000. This is true if browser calendar widget is used

  2. In tiddler text user enters #Task, #Proposal, … and on tiddler save they need to be converted into tags and added to tiddler tags field (there is a plugin for this, see links.tiddlywiki.org)

In summary one needs automate some actions and these can be done by TW on tiddler save.

Implementation

to allow average users do such actions without touching core tiddlers or need for using JS, Tiddlywiki can use modular actions (transcluded actions)

  1. TW can have a new tag like $:/tags/TiddlerSave/Actions
  2. One adds as many actions as required, all tagged with $:/tags/TiddlerSave/Actions
  3. Save button actions in ($:/core/ui/Buttons/save) then will be revised as below to include such actions on tiddler save
<$fieldmangler><$button actions='
<$list filter="[all[tiddlers+shadows]tag[$:/tags/TiddlerSave/Actions]!has[draft.of]">
<$transclude />
</$list>
'
..
1 Like

@Mohammad I already have a whole proposal for this which is close to what you ask - demonstrated here https://all-button-actions.tiddlyhost.com/

  • We need to request this as a core change but can use it as a plugin until then.
  • Basically if you use the right tag for any core button name to tag a tiddler containing additional actions it will be executed on clicking that button;

However in the example 1. you give it would be better to place An action to convert the date that comes from the date picker immediately, here is an example Date picker v1.json (1.1 KB)

In your second example you may very well use the tiddler save button as the trigger

  • Using my proposed all button actions solution you would place the actions in a tiddler tagged $:/tags/button-actions/save
1 Like