Dropdown menu to add one tag and remove another?

137 views
Skip to first unread message

Beckstrom

unread,
Aug 21, 2020, 7:49:49 PM8/21/20
to TiddlyWiki
Here's my use-case: I'm using TW as a task tracking system, and I'm using tags like "in progress" and "done" to show the status of a given tiddler/task (I call them "tidos" :-) )

What I'd like is to be able to have a dropdown menu of 3 items for instance: "inbox" "in progress" "done," and when I select one of them, that tag is added and the other two (if they exist in the tiddler) are removed. If I click the dropdown and choose "done," if the tiddler has the tag "inbox" or "in progress," those tags are removed, and the tag "done" is added

I know I can do this with fields, and that works too, except I'm using Dropboard (awesome! http://reidgould.github.io/tiddlywiki-dropboard ) which uses tags to move cards around. I'm primarily wanting this functionality because I can't move cards in Dropboard on my phone (something about HTML5 support I think)

I've been trying lots of stuff but can't get it quite the way I want... does anybody know if this is possible? Thanks in advance!

Eric Shulman

unread,
Aug 21, 2020, 9:12:58 PM8/21/20
to TiddlyWiki
On Friday, August 21, 2020 at 4:49:49 PM UTC-7, Beckstrom wrote:
What I'd like is to be able to have a dropdown menu of 3 items for instance: "inbox" "in progress" "done," and when I select one of them, that tag is added and the other two (if they exist in the tiddler) are removed.

Give this a try:
<$button popup=<<qualify $:/state/popup/setstatus>>>
   status:
   <$text text={{{ [
<currentTiddler>tag[inbox]then[inbox]] }}}/>
   <$text text={{{ [
<currentTiddler>tag[in progress]then[in progress]] }}}/>
   <$text text={{{ [
<currentTiddler>tag[done]then[done]] }}}/>
   <$text text={{{ [
<currentTiddler>!tag[inbox]!tag[in progress]!tag[done]then[none]] }}}/>
</$button>
<$reveal type="popup" state=<
<qualify $:/state/popup/setstatus>> class="tc-drop-down" style="min-width:auto;">
   <$button class="tc-btn-invisible"> none
      <$action-listops $tags="-[[inbox]] -[[in progress]] -[[done]]"/>
   </$button>
   <$button class="tc-btn-invisible"> inbox
      <$action-listops $tags="[[inbox]] -[[in progress]] -[[done]]"/>
   </$button>
   <$button class="tc-btn-invisible"> in progress
      <$action-listops $tags="[[in progress]] -[[inbox]] -[[done]]"/>
   </$button>
   <$button class="tc-btn-invisible"> done
      <$action-listops $tags="[[done]] -[[inbox]] -[[in progress]]"/>
   </$button>
</$reveal>

Notes:
1) The $button text shows the current status (none, inbox, in progress, done)
2) Clicking the $button shows a tc-drop-down containing four $buttons, one for each status value
3) The $buttons in the tc-drop-down use $action-listops to add the desired tag and remove the others
4) The "none" button removes all the status tags

To use:
1) Put the above into a tiddler (e.g., "SetStatus")
2) Transclude it into another tiddler using {{||SetStatus}}

Alternatively, if you want to add this to the tiddler toolbar for all tiddlers:
1) Put the above into a tiddler (e.g., "SetStatus")
2) Add tag "$:/tags/ViewToolbar"

Let me know how it goes...

enjoy,
-e

Beckstrom

unread,
Aug 24, 2020, 10:07:03 AM8/24/20
to TiddlyWiki
thank you SO MUCH! This is amazing, and exactly what I was trying to accomplish. Thanks for sharing your Tiddlywiki skills! I understand a little bit of what's happening in your code, but I definitely will be studying it more to learn.

Thanks again!

Reply all
Reply to author
Forward
0 new messages