Checkbox for removing tags?

517 views
Skip to first unread message

Casey Allan

unread,
Jan 12, 2016, 6:17:16 AM1/12/16
to TiddlyWiki
I've got tags adding with no issue...but I want the "In Progress" tag to be removed once I tick the box to complete it... I'm just not sure how to delete a tag.
 
! Outstanding tasks
<$list filter="[!has[draft.of]tag[task]!tag[In Progress]!tag[done]sort[created]]">
<$checkbox tag="In Progress"> <$link to={{!!title}}><$view field="title"/></$link></$checkbox>
</$list>
! In Progress...
<$list filter="[!has[draft.of]tag[task]tag[In Progress]sort[created]]">
<$checkbox tag="done"> <$link to={{!!title}}><$view field="title"/></$link></$checkbox>
</$list>
! Completed tasks
<$list filter="[!has[draft.of]tag[task]tag[done]sort[created]]">
<$checkbox tag="done"> ~~<$link to={{!!title}}><$view field="title"/></$link>~~</$checkbox>
</$list>

Any help is very much appreciated.
 
Cheers,
-C

Eric Shulman

unread,
Jan 12, 2016, 8:06:23 AM1/12/16
to TiddlyWiki
On Tuesday, January 12, 2016 at 3:17:16 AM UTC-8, Casey Allan wrote:
I've got tags adding with no issue...but I want the "In Progress" tag to be removed once I tick the box to complete it... I'm just not sure how to delete a tag.

Your first stop should always be to check the documentation on tiddlywiki.com:


According to those docs, you want to add invertTag="yes", which says:

"When set to yes, flips the tag binding logic so that the absence of the tag causes the checkbox to be checked"

Q.E.D.

enjoy,
-e

Tobias Beer

unread,
Jan 12, 2016, 8:19:54 AM1/12/16
to TiddlyWiki
Hi Eric,
 
According to those docs, you want to add invertTag="yes", which says:

"When set to yes, flips the tag binding logic so that the absence of the tag causes the checkbox to be checked"

I think the problem is that Casey wants to perform two actions in one checkbox,
and futhermore it appears that the CheckboxWidget is unfit to do so, see:

#2217 have CheckboxWidget trigger actions

~

@matabele, I tried to use the $action-listops widget and a button,
but it appears to fail to do what I want:

! Outstanding tasks
<$list filter="[!has[draft.of]tag[task]!tag[In Progress]!tag[done]sort[created]]">
<$checkbox tag="In Progress"> <$link to={{!!title}}><$view field="title"/></$link></$checkbox>
<
/$list>


! In Progress...
<$list filter="[!has[draft.of]tag[task]tag[In Progress]sort[created]]">
<$button class="tc-btn-invisible"><input type="checkbox"/><$action-listops $field="tags" $subfilter="+done -[[In Progress]]"/></$button>

<$link to={{!!title}}><$view field="title"/></$link>
</$list>

! Completed tasks
<$list filter="[!has[draft.of]tag[task]tag[done]sort[created]]">
<$checkbox tag="done"> ~~<$link to={{!!title}}><$view field="title"/
></$link>~~</$checkbox>
</$list>

Also, how to use $action-listops with the $tags attribute while preserving the existing tags?!?

Best wishes,

Tobias. 

Eric Shulman

unread,
Jan 12, 2016, 11:00:41 AM1/12/16
to TiddlyWiki
On Tuesday, January 12, 2016 at 5:19:54 AM UTC-8, Tobias Beer wrote:
Hi Eric,
 
According to those docs, you want to add invertTag="yes", which says:

"When set to yes, flips the tag binding logic so that the absence of the tag causes the checkbox to be checked"

I think the problem is that Casey wants to perform two actions in one checkbox,
and futhermore it appears that the CheckboxWidget is unfit to do so, see:

Casey very clearly stated his goal:
"I want the "In Progress" tag to be removed once I tick the box"

Only *one* action.... remove a tag when a checkbox is clicked (or set the tag when the checkbox is cleared)

That is *exactly* what the "invertTag" parameter accomplishes.  

-e

Tobias Beer

unread,
Jan 12, 2016, 11:55:47 AM1/12/16
to TiddlyWiki
Hi Eric,
 
Only *one* action.... remove a tag when a checkbox is clicked (or set the tag when the checkbox is cleared)

That is *exactly* what the "invertTag" parameter accomplishes.  

The way I interpreted it is that a task is to move from In Progress to done.
This requires for a checkbox to both:
  1. remove the In Progress tag
  2. add the done tag
By the way, when using tags, I'd recommend using the same spelling for those in the same bucket. So, I'd be using something like active. rather than In Progress. In fact, I'd be using: #future, #next, #active, #waiting, #done.

Best wishes,

Tobias.

Matabele

unread,
Jan 12, 2016, 1:26:20 PM1/12/16
to TiddlyWiki
Hi Tobias

The $tags= attribute accepts a subfilter, which is applied as a run to the the existing contents of the 'tags' field -- so use:

<$action-listops $tags="done -[[In Progress]]"/>

AS far as I remember, I included this option to render the setting/unsetting of tags as quick and easy as possible.

It could also be done using the $filter= attribute -- like this:

<$action-listops $field="tags" $filter="[list[!!tags]] done -[[In Progress]]"/>

or like this:

<$button><$action-listops $field="tags" $subfilter="done -[[In Progress]]"/>Set</$button>

The $tags= attribute is simply a shortcut.

regards

On Tuesday, 12 January 2016 15:19:54 UTC+2, Tobias Beer wrote:
@matabele, I tried to use the $action-listops widget and a button,
but it appears to fail to do what I want:
! In Progress...
<$list filter="[!has[draft.of]tag[task]tag[In Progress]sort[created]]">
<$button class="tc-btn-invisible"><input type="checkbox"/
><$action-listops $field="tags" $subfilter="+done -[[In Progress]]"/></$button>
<$link to={{!!title}}><$view field="title"/></$link>
</$list>

Tobias Beer

unread,
Jan 12, 2016, 1:53:16 PM1/12/16
to TiddlyWiki
Hi Matabele,

Ah, I see what I did wrong before now. Find the error:

<$button class="tc-btn-invisible"><input type="checkbox"/><$action-listops $field="tags" $subfilter="+done -[[In Progress]]"/></$button>

:-)

Ok, so this should work for you Casey:

! Backlog

<$list filter="[!has[draft.of]tag[task]!tag[active]!tag[done]sort[created]]">
<$checkbox tag="active">

<$link to={{!!title}}><$view field="title"/></$link>
</$checkbox>
<br>
</
$list>

! In Progress...
<$list filter="[!has[draft.of]tag[task]tag[active]sort[created]]">

<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="done -active"/>

</$button>
<$link to={{!!title}}><$view field="title"/
></$link>
<br>
</$list>

! Completed Tasks


<$list filter="[!has[draft.of]tag[task]tag[done]sort[created]]">
<$checkbox tag="done">
~~<$link to={{!!title}}><$view field="title"/></$link>~~
</$checkbox>
<br>
</
$list>

Best wishes,

Tobias.

Matabele

unread,
Jan 12, 2016, 2:06:38 PM1/12/16
to TiddlyWiki
Hi Tobias

Shouldn't close the <input type="checkbox"> with />

regards

Tobias Beer

unread,
Jan 12, 2016, 2:19:32 PM1/12/16
to TiddlyWiki
Hi Matabele,
 
Shouldn't close the <input type="checkbox"> with />

Not quite. It was the little before the done tag
which essentially removed all previous tags while adding the tag done. ;-)

Best wishes,

Tobias.

Casey Allan

unread,
Jan 13, 2016, 5:30:30 AM1/13/16
to tiddl...@googlegroups.com
<$list filter="[!has[draft.of]tag[task]!tag[active]!tag[done]sort[created]]">
<$checkbox tag="active">

<$link to={{!!title}}><$view field="title"/></$link>
</$checkbox>
<br>
</
$list>

! In Progress...
<$list filter="[!has[draft.of]tag[task]tag[active]sort[created]]">
<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="done -active"/>

</$button>
<$link to={{!!title}}><$view field="title"/
></$link>
<br>
</$list>

! Completed Tasks


<$list filter="[!has[draft.of]tag[
task]tag[done]sort[created]]">
<$checkbox tag="done">
~~<$link to={{!!title}}><$view field="title"/
></$link>~~
</$checkbox>
<br>
</
$list>
 
Thanks for the feedback -- I did want to remove the In progress/active tag and add the done tag. I'll atempt to be clearer nex time!
 
I can't get the correction with the button to work, though, Tobias - it doesn't list the tasks at all under the In Progress... header. All I get is one lone checkbox.

Tobias Beer

unread,
Jan 13, 2016, 11:33:18 AM1/13/16
to TiddlyWiki
Hi Casey,
 
I can't get the correction with the button to work, though, Tobias - it doesn't list the tasks at all under the In Progress... header. All I get is one lone checkbox.

I feared this might happen. ;-)

It's because I was so so sneaky as to change the tag from In Progress to active
So, you can either search and replace it back or...

Best wishes,

Tobias.

Matabele

unread,
Jan 13, 2016, 11:59:45 PM1/13/16
to TiddlyWiki
Hi Casey

An alternative approach which might suit your usage case:
-- each click of the button will choose the next tag in the list from the 'list' field of the currentTiddler
-- place the list of tags you wish to cycle through in the 'list' field

<$button>
<$action-listops $tags="[list[]first[]] -[list[]last[]]" $subfilter="+[putlast[]]"/>
Tag</$button>

list: todo active done

The button code may be written in the form of a global macro (<<cycleTag>> macro tiddler attached).

The list field is required for every task tiddler:
-- the state of the tag for each task is recorded by way of the order of the tags in this field
-- place the list (starting order) in the template for a new task

regards
Cycle Tag Macro.tid

Casey Allan

unread,
Jan 15, 2016, 4:27:49 AM1/15/16
to TiddlyWiki
Thanks :)
 
I changed things to "active", "waiting" and "done" .
 
All is happy on the tasklist front.
 
Cheers,
-C

Casey Allan

unread,
Jan 15, 2016, 4:29:46 AM1/15/16
to TiddlyWiki
Oh, this is cool. Thanks, Matabele.
 
Cheers,
-C

Matabele

unread,
Jan 15, 2016, 4:45:56 AM1/15/16
to TiddlyWiki
Hi Casey

You might like to have a look at my new cycle[] filter operator from here. If you like this solution, copy across the modified version of the '$:/core/modules/filters/x-listops.js' filters to your wiki (from the More/Systems tab.)

This mechanism has several advantages over my previous <<cycleTags>> macro:
-- only one reference list required
-- no conflicts between multiple buttons cycling the same tag
-- can work forward/reverse
-- can cycle multiple items in multiple lists/tiddler

If you prefer this in the form of a macro, this works much like the old macro (taking values from the 'list' field of the current tiddler):

\define cycleTags()
<$button>
<$action-listops $tags="+[cycle{!!list}]"/>
Cycle Tag</$button>
\end

-- or, even simpler:

\define cycleStatus()
<$button>
<$action-listops $tags="+[cycle[active waiting done]]"/>
Cycle Status</$button>
\end

regards

Andrew Whiting

unread,
Feb 2, 2016, 10:24:06 AM2/2/16
to TiddlyWiki
Hi Matabele,

I stumbled across this thread and was wondering if there is a way to combine your cycle [] filter operator with a checkbox so that checking the box removes one tag and adds the next in the cycle? I'm new to TIddlyWiki and am not in any way a programmer so hopefully that's not a dumb question...

For some added context, I'm pulling in a linked list of the titles of all tiddlers tagged "Review" that were created 2, 7, 14, 28 etc days ago (as a way of systematically reviewing class notes). I would like to use your cycle filter operator to make it so that checking the box next to the title removes "Review" and adds "Review 2" (or removes "Review 2" and adds "Review 3" and so on) to bump the tiddler into the next group with a longer waiting period.

I've been at it for hours and am stumped haha.

Thanks in advance!

Matabele

unread,
Feb 2, 2016, 10:36:47 AM2/2/16
to TiddlyWiki
Hi Andrew

The state of a checkbox (checked/unchecked) is tied to the presence/absence of an item in a list. When cycling a tag, therefore, what should the state of the checkbox reflect?

Rather build a button which cycles the tag on each click -- the current state can be displayed (on the button, if you wish) with the keep[] operator (designed specifically for this purpose.)

There's an example of this on the demo website here -- flip through the slides to keep[] Operator (Examples), and repeatedly click any of the tags at the bottom of the page. This should be something like what you're after.

You'll need the version of the x-listops.js filters from the demo site (which includes the cycle[] and keep[] operators) -- then adapt the code from the aforementioned example.

regards

Matabele

unread,
Feb 2, 2016, 10:49:33 AM2/2/16
to TiddlyWiki
Hi Andrew

On checking the demo site -- it isn't obvious that the buttons are cycling tags from the tags field of the target tiddler (as the tiddlers are open in a substory without the tag pills displayed.) If you wish to see this, open any of the target tiddlers from the sidebar (perhaps, Modals) -- then you can see the tag pills themselves cycling on the target tiddler.

The buttons have been set up to cycle and display the tags -- any other action widgets could be added to the buttons to do other stuff at the same time.

regards

On Tuesday, 2 February 2016 17:24:06 UTC+2, Andrew Whiting wrote:

Andrew Whiting

unread,
Feb 2, 2016, 10:53:29 AM2/2/16
to TiddlyWiki
The problem is that I have multiple titles in my list (I attached a pic) so I was hoping not to end up with a bunch of buttons.

If I understand correctly, the state of the checkbox would reflect the presence of a "Review" (or some iteration of it) tag. By clicking it, I would remove "Review" and add "Review 2." This would both remove that title from my list and get it ready to pop up on my list again after x days because I would be pulling in anything tagged Review that's 3 days old, anything tagged Review 2 that's a week old, anything tagged Review 3 that's 2 weeks old on so on. 

If you tell me it won't work I'll believe you and build the button. I just hoping your cycle filter would be a pretty solution to my problem.

Thanks!
Screen Shot 2016-02-02 at 4.46.13 PM.png

Andrew Whiting

unread,
Feb 2, 2016, 11:00:25 AM2/2/16
to TiddlyWiki
Awesome, that was confusing me. Thanks!

Matabele

unread,
Feb 2, 2016, 11:04:03 AM2/2/16
to tiddl...@googlegroups.com
Hi Andrew

In the demo, each of the 'tag buttons' is cycling a different tag on a different tiddler. For your usage case, you'd need only a single 'tag button':

<ul><$list filter="[tag[ToReview]]"> <li> <$link><<currentTiddler>> </$link>
<$button class="tc-btn-invisible" tooltip="cycle period">
<$action-listops $tags="+[cycle[Review1 Review2 Review3 Review4]"/>
@<$list filter="[is[current]tags[]] +[keep[Review1 Review2 Review3 Review4]]" variable="item"><<item>></$list>
</$button>
</li></ul>

The top filter lists all of the tiddlers tagged 'ToReview'  -- and the <$link><<cuurentTiddler>></$link> displays the title of the tiddler as a link.

The button alongside will cycle through your four tags for that tiddler.

Bare in mind, that when specified like this, the list of tags can not contain spaces. If any of your tags contain spaces, you must use a reference to a list in a field or variable (as in the example.)

regards

Andrew Whiting

unread,
Feb 2, 2016, 11:20:05 AM2/2/16
to TiddlyWiki
Hi Matabele

Okay, I'll see if I can make that work. It's not displaying a button for some reason but I'm really new at this so I'll keep working on it.

Thanks so much for your time and help!

Andrew

Matabele

unread,
Feb 2, 2016, 11:24:31 AM2/2/16
to TiddlyWiki
Hi Andrew

Note the @ I've placed before the expression with the keep[] operator -- this is so that the '@' shows as a button if the tiddler contains none of the tags in the list.

The @ can be replaced with anything -- a string of text or an icon for example.

regards

Matabele

unread,
Feb 2, 2016, 11:36:27 AM2/2/16
to TiddlyWiki
Hi Andrew

Oops -- I left out a </$list> at the bottom there.

regards

Matabele

unread,
Feb 2, 2016, 11:43:35 AM2/2/16
to TiddlyWiki
Hi Andrew

OK -- tested this in a TW now :-) Place this code in a tiddler, and place the list of tags in the list field (of the same tiddler.)

<ul>
<$list filter="[tag[ToReview]]">
<li>

<$link><
<currentTiddler>> </$link></li>

<$button class="tc-btn-invisible" tooltip="cycle period">
<$action-listops $tags="+[cycle{!!list}]"/>
@ <$list filter="[is[current]tags[]] +[keep{!!list}]" variable="item"><
<item>></$list>
</$button>
</$list>
</ul>

regards

Andrew Whiting

unread,
Feb 2, 2016, 11:47:17 AM2/2/16
to TiddlyWiki
That was it haha. I should have seen that. I told you I'm very new at this. 

Thanks!

Dave

unread,
Jan 29, 2017, 11:29:17 PM1/29/17
to TiddlyWiki
I'm trying to get this working in my TW and am struggling:

this:

\define cycleStatus()
<$button>
<$action-listops $tags="+[cycle[active waiting done]]"/>
Cycle Status</$button>
\end

<<cycleStatus>>


causes the TW to need changes saved (the "save" icon turns red") but nothing happens - I was expecting the tiddler to cycle through the three tags

and this one:


<ul>
<$list filter="[tag[ToReview]]">
<li>

<$link><
<currentTiddler>> </$link></li>

<$button class="tc-btn-invisible" tooltip="cycle period">
<$action-listops $tags="+[cycle{!!list}]"/>
@ <$list filter="[is[current]tags[]] +[keep{!!list}]" variable="item"><<item>></$list>
</$button>
</$list>
</ul>

(with "
ToReview" changed to a tag that I have in use) also causes unseen changes
(yes, I added a field "list" with a few words in it to use as tags)


What am I doing wrong?  My version is
5.1.13
Reply all
Reply to author
Forward
0 new messages