Greetings,
I’ve been trying to evolve my learning and wanted to take a tool I have to toggle a list of tiddlers between two tags. Clicking an item will toggle it from #q1 to #q2 or vice versa:
#q1
[ ] Item 1
[ ] Item 2
#q2
[ ] Item 3
[ ] Item 4
The code below works great…
!#q1
<$list filter="[tag[#q1]]">
<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="#q2 -#q1"/>
</$button>
<$link to={{!!title}}><$view field="title"/></$link>
<br>
</$list>
!#q2
<$list filter="[tag[#q2]]">
<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="#q1 -#q2"/>
</$button>
<$link to={{!!title}}><$view field="title"/></$link>
<br>
</$list>
…, however, I want to up my game by only having to define the tags in one place, rather than change them everywhere each time.
After much struggle I am so close but am stumped with how to define the variable in the $action-listops sections:
<$set name="firstTag" value=#q1>
<$set name="secondTag" value=#q2>
Clicking on a checkbox will move that item from <<firstTag>> to <<secondTag>> or vice versa
!<<firstTag>>
<$list filter="[tag<firstTag>]">
<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="-<<firstTag>> <<secondTag>>"/>
</$button>
<$link to={{!!title}}><$view field="title"/></$link>
<br>
</$list>
!<<secondTag>>
<$list filter="[tag<secondTag>]">
<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="<<firstTag>> -<<secondTag>>"/>
</$button>
<$link to={{!!title}}><$view field="title"/></$link>
<br>
</$list>
</$set>
</$set>
These are the lines giving me trouble. I am trying to remove the #q1 tag and add the #q2 tag in the first section:
<$action-listops $tags="-<<firstTag>> <<secondTag>>"/>
And the reverse in the second section:
<$action-listops $tags="<<firstTag>> -<<secondTag>>"/>
I managed to figure out to use single brackets in the filter, double brackets elsewhere, but in the $action-listops portion I have tried double brackets, single brackets, $$ signs, $()$ signs, crying, cursing and throwing up my hands…, all to no avail. I feel like I am missing something obvious. Any help would be much appreciated.