I have long wanted to gather multiple operations together to apply to a tiddler with a single click, for example add a tag, remove a tag, set or change a fields value. I have explored this from a few different directions but think I have found an approach and would hope those interested may review and contribute;
- I would hope to build a concensus so we could set a standard and thus share “action tiddlers”
- This could work in tiddlywiki 5.2.x however the filter “functions” will allow us to create even simpler custom filters and filter operators.
Imagin a system tiddler called “Make reference” (an action tiddler), its intention is to provide an action on todo tiddlers, which can be converted to a reference tiddler.
- In this case we start with a display-filter field containing `[all[current]tag[todo]]" which says only make this action/button available if the current tiddler has a todo tag.
Now what will happens if the button “make reference” is now visible and we click it?, lets add some fields to our action tiddler, of the form actions-fieldname
- action-tags
- actions-object-type
- actions-due-date
Now lets add our “action filter” to each “action field”
- action-tags
[all[current]tags[]] [[reference]] -[[todo]]
add reference tag, remove todo retain others - actions-object-type
[[reference]]
set to reference ignoring previouse value - actions-due-date `` clear due-date
You can see in the above filters, if you need to retain current value(s), comon for lists like tags, you have to first retrive it, the filter is then used to set the new value of that field on the current tiddler. that is the result of the filter replaces the value.
For each action-field we will generate an action, for example;
<$action-setfield $field="tags" $value={{{ [all[current]tags[]] [[reference]] -[[todo]] }}}/>
In this way we can build a generic button that will use any action tiddler where the display-filter has a result, and on click will action the named fields as defined, replacing them with new values.
An example with 5.3.x is replace the tags action filter with a custom operator
-
[current.tags[reference],[todo]]
first parameter one or more tags to add, second parameter one or more tags to remove.
What do you think?
- What else would to add to such action tiddlers?
- How could we use the modifier keys, and set a tooltip etc…