[TW5] Nested lists - referring to title of parent list item

452 views
Skip to first unread message

Matthew Petty

unread,
Mar 15, 2016, 6:38:36 AM3/15/16
to TiddlyWiki
I want to create a table to record the BMIS (brief mood introspection scale - a psychological tool). This is a set of 16 emotional  items, for which you record one of four graded responses.
For example, for the emotion "Happy", you record XX, X, V, or VV (these represent how strongly you feel that emotion). I want to include this table in a journal skeleton, so that clicking radio buttons will set a field for each of the 16 items with one of the four values.

I could create this table manually, but that would be tedious and involve lots of copying, pasting and changing. Here's what that would look like:

|      |XX  X  V  VV|
|Lively|<$radio field="BMIS-Lively" value="XX"></$radio> <$radio field="BMIS-Lively" value="X"></$radio> <$radio field="BMIS-Lively" value="V"></$radio> <$radio field="BMIS-Lively" value="VV"></$radio>|<$view field="BMIS-Lively"/>|
|Happy |<$radio field="BMIS-Happy" value="XX"></$radio> <$radio field="BMIS-Happy" value="X"></$radio> <$radio field="BMIS-Happy" value="V"></$radio> <$radio field="BMIS-Happy" value="VV"></$radio>|
etc

So rather than that I want to try to do it using nested lists to generate the table. I'm stuck though.

I've created 16 tiddlers for the emotions, in the form BMIS_01_Lively, BMIS_02_Happy etc. (List A)
I've created 4 tiddlers for the grading, in the form BMIS_XX etc (List B)

The rows are based on the tiddlers in List A. The columns are based on the tiddlers in List B. For each item in List A, I want to show 4 radio buttons, representing 4 possible values. The buttons would set a field with the same name as the title of the row tiddler with the chosen value.

Here's what I have (see http://mjp-tw5-test.tiddlyspot.com/#BMIS%20Recording):

<table>
<$list filter="[prefix[BMIS]!title[BMIS_Scale]!tag[BMIS_Scale]!each[title]]">
<tr>
<td>
<$view field="title"/>
</td>
<$list filter="[tag[BMIS_Scale]]">
<td><$radio field="TITLE OF TIDDLER IN FIRST LIST" value="TITLE OF TIDDLER IN THIS LIST"></$radio></td></$list></tr></table></$list>

How can I get the title of the parent tiddler in the nested list? Also, how do I get the table to format correctly?











Mat

unread,
Mar 15, 2016, 7:29:16 AM3/15/16
to TiddlyWiki
Something like this should work. Note that you had the level of the final closing list and closing table tags juxtaposed.

<table>
<$list filter="[[aa]] [[bb]] [[cc]]" variable="item">
<tr>
   
<td><$view field="title"/></td>

   <$list filter="[[dd]] [[ee]] [[ff]]">
   
<td><$radio field=<<item>> value={{!!title}}></$radio></td>
   </$list>
</tr>
</$list>
</table>

Matthew Petty

unread,
Mar 15, 2016, 8:33:23 AM3/15/16
to TiddlyWiki
Yes I did! Woops.

That was helpful, thank you very much. Now I have this: http://mjp-tw5-test.tiddlyspot.com/#BMIS_Recording

<table>
<tr><td></td><td>XX</td><td>X</td><td>V</td><td>VV</td><td>val</td></tr>
<$list filter="[!has[draft.of]prefix[BMIS]!title[BMIS_Scale]!tag[BMIS_Scale]sort[title]]" variable="item">
<tr>
   
<td><$link to=<<item>>><<item>></$link></td>

   <$list filter="[[BMIS_XX]] [[BMIS_X]] [[BMIS_V]] [[BMIS_VV]]">
   
<td><$radio field=<<item>> value={{!!title}}></$radio></td>
   </$list>
<td><<item>> = <$view field=<<item>> /></td>
</tr>
</$list>
</table>

This is closer, but there are still some issues.
1. I can select more than one of the values for each row. The radio buttons should mean that only one is selected.
2. The extra column at the end should now display the value of the field being set. It's not showing anything.

The idea with this is to include it in a journal skeleton, then each journal created from that skeleton will have this table in it, and then the fields can be set. Then that journal entry will have the 16 fields, each with one of 4 values.

Matthew Petty

unread,
Mar 20, 2016, 8:59:05 AM3/20/16
to TiddlyWiki
Any further suggestions here?

Matthew Lauber

unread,
Mar 20, 2016, 12:53:37 PM3/20/16
to TiddlyWiki
Not sure on the first question, but the second one is because the radio widget doesn't specify a tiddler. Therefore it uses the currentTiddler which is the same as {{!!title}}. Specify that in both the radio and view widgets to solve the second point.

Julio Cantarero

unread,
Mar 20, 2016, 4:00:56 PM3/20/16
to TiddlyWiki
Hi,

I took your latest version, and did some changes. I think the problem is that you were setting the fields in the BMIS_Scale tiddlers, not in the BMIS_Recording one, so you have multiple fields with the same name in multiple tiddlers.
With the proposal below, all the radio buttons in the same row apply to the same field and thus only one value can be set at a given time.

<$set name="thisTiddler" value=<<currentTiddler>> >
<table>
<tr><td></td><td>XX</td><td>X</td><td>V</td><td>VV</td><td>val</td></tr>

<$list filter="[!has[draft.of]prefix[BMIS]!tag[BMIS_Scale]!title[BMIS_Scale]!title[BMIS_Recording]sort[title]]" variable="item">
<tr>
   
<td><$link to=<<item>>> <<item>> </$link></td>


   <$list filter="[tag[BMIS_Scale]]">
   
<td><$radio tiddler=<<thisTiddler>> field=<<item>> value={{!!title}}></$radio></td>

   </$list>
<td><<item>> = <$view field=<<item>> /></td>
</tr>
</$list>
</table>

</$set>

Anyway, I think you want this expression to be a template, so that you can record this mood states for different people. In this case, you need to enclose all the above in a condition, add the tag $:/tags/ViewTemplate and use the tag BMIS_Record in each tiddler where you record the mood information for each person (You can choose a tag different to BMIS_Record, just change the tag name in the filter of the $list condition below.


<$list filter="[all[current]tag[BMIS_Record]]">
 (... code above ...)
</$list>

If you want more details about this latter part, please check http://tobibeer.github.io/tb5/#Conditional%20ViewTemplate%20Section
Regards,

Julio

Reply all
Reply to author
Forward
0 new messages