Long post warning 
It is very common to extend some wikitext code, once it works. As you can see, there are some elements, that are duplicated, or the code used is very similar. Eg:
-
The $:/temp/new-**
tiddler titles. They are duplicated a lot.
-
The action-setfield
code-block stands out there are only tiny differences, but a lot to type.
<$action-setfield $tiddler="$:/temp/new-tiddler-title" text=""/> <!--Limpia el título del tiddler-->
<$action-setfield $tiddler="$:/temp/new-tiddler-tag" text=""/> <!--Limpia los tags de objeto-->
<$action-setfield $tiddler="$:/temp/new-tiddler-tag-domain" text=""/> <!--Limpia los tags de dominio-->
IMO it would be much nicer, if we could have 1 command, instead of 3.
- In TW we call variables, that have the following structure:
$:/temp/something
namespace variables.
- So all variables, which start with
$:/temp/
are part of the “temp namespace”.
- If I want to list in Advanced Search → Filter tab, I can use a filter like this:
[prefix[$:/temp/]]
So I could delete all temporary tiddlers with:
<$action-deletetiddler $filter="[prefix[$:/temp/]]"/>
The problem with that delete function is, that it deletes every temporary tiddler in the system → That’s not what we need.
So should make the namespace more specific. eg: $:/temp/rosi/
– So we only delete “Rosi’s” temp tiddlers. I did do exactly that in the following code rewrite.
To do that I did define some more “tiddler title” functions.
- Temp tiddlers get a
/rosi/
namespace
- The “tag” tag and the “domain” tag have new functions now
Wo we can easily rename them in the future if we need to. eg. If we need a different namespace.
<!-- Define temporary tiddler titles -->
\function f.tempTiddler() $:/temp/rosi/new-tiddler-title
\function f.tempTag() $:/temp/rosi/new-tiddler-tag
\function f.tempDomain() $:/temp/rosi/new-tiddler-domain
We already know the following code, but I did add a bit more comments, to make it clearer, what it does and why.
<!-- Function to "get" a whitespace trimmed new tiddler title.
Trimming whitespace here is important, since users can enter the new title.
If they accidentally use a leading or trailins space, that can cause problems.
-->
\function f.getNewTitle() [<f.tempTiddler>get[text]trim[]]
In the OP you wrote, that you had a problem with “combining” tags. Eric already posted a fix for that one. I did use a new function. I named it: f.getTags – See the plural. It returns a tag-string, that can be used like that: tags=<<f.getTags>>
, which imo is much easier to read then a long filter string using all the $:/temp/...
variable.
New code to <<f.getTags>>
<!-- Function to "get" multiple tags and format them as a titlelist
titlelist see: https://tiddlywiki.com/#format%20Operator
-->
\function f.getTags() [<f.tempTag>get[text]] [<f.tempDomain>get[text]] +[format:titlelist[]join[ ]]
I did also extend the dropdowns a little bit. They got several new elements, so it looks like this:
- Description which is a disabled option
- An “-none-” option, which is use to define an empty string “”
- You will need to translate this one into Spanish
- The select-widget got a
default=""
parameter.
<$select tiddler=<<f.tempTag>> field="text" default="">
- Also see the
<<f.tempTag>>
function name
So the first select looks as follows:
<!-- Dropdown para seleccionar una etiqueta sobre el tipo de OBJETO-->
2. Elige una de las etiquetas del menú desplegable. <br>
<$select tiddler=<<f.tempTag>> field="text" default="">
<option disabled>Selecciona una etiqueta</option>
<option value="">-none-</option>
<option value="Costs">Costs</option>
<option value="Issues">Issues</option>
<option value="Parameter">Parameter</option>
<option value="Community">Community</option>
</$select>
The full code
Which is tested and seems to work for me.
<!-- Define temporary tiddler titles -->
\function f.tempTiddler() $:/temp/rosi/new-tiddler-title
\function f.tempTag() $:/temp/rosi/new-tiddler-tag
\function f.tempDomain() $:/temp/rosi/new-tiddler-domain
<!-- Function to "get" a whitespace trimmed new tiddler title.
Trimming whitespace here is important, since users can enter the new title.
If they accidentally use a leading or trailins space, that can cause problems.
-->
\function f.getNewTitle() [<f.tempTiddler>get[text]trim[]]
<!-- Function to "get" multiple tags and format them as a titlelist
titlelist see: https://tiddlywiki.com/#format%20Operator
-->
\function f.getTags() [<f.tempTag>get[text]] [<f.tempDomain>get[text]] +[format:titlelist[]join[ ]]
<!-- Helper procedures -->
\procedure deleteTempTiddlers()
<$action-deletetiddler $filter="[prefix[$:/temp/rosi/]]" />
\end
\procedure newTiddlerActions()
<% if [<f.getNewTitle>has[text]] %>
<$action-navigate $to=<<f.getNewTitle>>/>
<%else%>
<$action-sendmessage $message="tm-new-tiddler"
title=<<f.getNewTitle>>
tags=<<f.getTags>>
text="Este es un tiddler con etiqueta"
/>
<!-- delete all temporary tiddlers -->
<<deleteTempTiddlers>>
<%endif%>
\end
<!-- Campo para introducir el título del nuevo tiddler -->
1. Introduce un título:<br>
<$edit-text tiddler=<<f.tempTiddler>> field="text" tag="input" class="tc-edit-textinput"/>
<!-- Dropdown para seleccionar una etiqueta sobre el tipo de OBJETO-->
2. Elige una de las etiquetas del menú desplegable. <br>
<$select tiddler=<<f.tempTag>> field="text" default="">
<option disabled>Selecciona una etiqueta</option>
<option value="">-none-</option>
<option value="Costs">Costs</option>
<option value="Issues">Issues</option>
<option value="Parameter">Parameter</option>
<option value="Community">Community</option>
</$select>
<!-- Dropdown para seleccionar una etiqueta sobre el tipo de DOMINIO -->
Elige un tipo de DOMINIO:
<$select tiddler=<<f.tempDomain>> field="text" default="">
<option disabled>Selecciona una etiqueta</option>
<option value="">-none-</option>
<option value="Regulation">Regulation</option>
<option value="Envi.& Nature">Nature</option>
<option value="Wellness">Wellness</option>
<option value="Water">Water</option>
</$select>
<!-- Botón para crear el tiddler con ese nombre -->
3. Presiona el botón "Crear nuevo tiddler" <br>
<$button actions=<<newTiddlerActions>> >
Crear nuevo tiddler
</$button>
Which looks like this:
have fun!
Mario