Different actions to different tiddlers with one click/button possible?

135 views
Skip to first unread message

The Bo

unread,
Feb 15, 2017, 11:20:08 AM2/15/17
to TiddlyWiki
Hey,

I try to build some sort of "TOC-toggle" where I want to remove not used TOC-Tiddlers temporarily so that they won't be displayed in the TOC.
The TOC is structured like this:

01
  010
   011
      0110
          01100
          01111
      0111
02
...

I already found a way to bring back TOC-Tiddler with the following code:
<$button>
<$fieldmangler tiddler=<
<currentTiddler>>>
<$set name="digit-pattern4" value="(^[0-9]{5}\s)">
<$list filter="[is[tag]!tag[#]has[toc_inactive]regexp:title
<digit-pattern4>]">
<$action-setfield $field='tags' $value={{!!toc_inactive}}/>
<$action-deletefield toc_inactive/>
</$list>
<$set name="digit-pattern3" value="(^[0-9]{4}\s)">
<$list filter="[is[tag]!tag[#]has[toc_inactive]regexp:title
<digit-pattern3>]">
<$action-setfield $field='tags' $value={{!!toc_inactive}}/>
<$action-deletefield toc_inactive/>
</$list>
<$set name="digit-pattern2" value="(^[0-9]{3}\s)">
<$list filter="[is[tag]!tag[#]has[toc_inactive]regexp:title
<digit-pattern2>]">
<$action-setfield $field='tags' $value={{!!toc_inactive}}/>
<$action-deletefield toc_inactive/>
</$list>
<$set name="digit-pattern1" value="(^[0-9]{2}\s)">
<$list filter="[is[tag]!tag[#]has[toc_inactive]regexp:title
<digit-pattern1>]">
<$action-setfield $field='tags' $value={{!!toc_inactive}}/>
<$action-deletefield toc_inactive/>
</$list>
</$set>
</$set>
</$set>
</$set>
</$fieldmangler>
</$button>

The Problem is, that I have to click four times. ;-)

Is there a simple way to do it in one click?

Regards
The Bo

PMario

unread,
Feb 15, 2017, 7:16:37 PM2/15/17
to TiddlyWiki
Hi,

On Wednesday, February 15, 2017 at 5:20:08 PM UTC+1, The Bo wrote:
I try to build some sort of "TOC-toggle" where I want to remove not used TOC-Tiddlers temporarily so that they won't be displayed in the TOC.
The TOC is structured like this:

01
  010
   011
      0110
          01100
          01111
      0111
02
...

Interesting. .. So you don't want the "selective-expandable" but the full TOC. ... But clicking a button you'll want to disable different levels. ... eg:

tree -L 2 will show

01
  010
  011
02

tree -L 3 will show

01
   010
   011
      0110
      0111
02

right. .. but you want to have only one command eg: going from -L 1 directly to -L 4. right?

-mario


The Bo

unread,
Feb 16, 2017, 9:02:05 AM2/16/17
to TiddlyWiki


Am Donnerstag, 16. Februar 2017 01:16:37 UTC+1 schrieb PMario:
Hi,

On Wednesday, February 15, 2017 at 5:20:08 PM UTC+1, The Bo wrote:
I try to build some sort of "TOC-toggle" where I want to remove not used TOC-Tiddlers temporarily so that they won't be displayed in the TOC.
The TOC is structured like this:

01
  010
   011
      0110
          01100
          01111
      0111
02
...

Interesting. .. So you don't want the "selective-expandable" but the full TOC. ... But clicking a button you'll want to disable different levels. ... eg:

Sorry, that was a bad example. In fact I use the selective-expandable TOC. It was just for a better understanding. I will try to explain it better:

My Structure:

01 Topictiddler
  010 Subtopic
   011 Subtopic
      0110 Subsubtopic
          01100 Subsubsubtopic
              Tiddler A
              Tiddler B
          01101 Subsubsubtopic
              Tiddler C
      0111 Subsubtopic
          01110       -> There is no Tiddler connected, so I want to toggle this tiddler.
02 Topictiddler

I "toggle" the tiddler 01110 by adding a field "toc_inactive" with the value {{!!tags}} and delete the tags. Like this the tiddler won't be found in the TOC but isn't deleted.
The next instance is:

01 Topictiddler
  010 Subtopic
   011 Subtopic
      0110 Subsubtopic
          01100 Subsubsubtopic
              Tiddler A
              Tiddler B
          01101 Subsubsubtopic
              Tiddler C
      0111 Subsubtopic    -> There is no Tiddler connected, so I want to toggle this tiddler.
02 Topictiddler

.... and so on.

Now hypothetically I want to tag Tiddler D with the tag "01110" which is currently inactive. This is the point where I'm searching for a solution to toggle the tiddlers "0111" and "01110" with one click.


tree -L 2 will show
 
01
  010
  011
02

tree -L 3 will show

01
   010
   011
      0110
      0111
02

right. .. but you want to have only one command eg: going from -L 1 directly to -L 4. right?

-mario
Exactly.

PMario

unread,
Feb 16, 2017, 9:58:01 AM2/16/17
to TiddlyWiki
On Thursday, February 16, 2017 at 3:02:05 PM UTC+1, The Bo wrote:
Now hypothetically I want to tag Tiddler D with the tag "01110" which is currently inactive. This is the point where I'm searching for a solution to toggle the tiddlers "0111" and "01110" with one click.

I think I understand now.

01 Topictiddler
  010 Subtopic   <-  imo should not be shown, right?

  011 Subtopic
      0110 Subsubtopic
          01100 Subsubsubtopic
              Tiddler A
      0111 Subsubtopic
          01110       -> There is no Tiddler connected, so I want to toggle this tiddler

0111 has the "expand icon" because 01110 exists. ... _but_ .... 01110 has no "content tiddler" so it is basically empty. ... that's why you don't want to show the branch, if there is no leaves. .. where a leave is eg: Tiddler A.  right?

So the function may be called: "Toggle empty branch visibility"

-mario

The Bo

unread,
Feb 16, 2017, 10:16:21 AM2/16/17
to tiddl...@googlegroups.com
Yes, exactly!
Right now every empty branch is already not visible because I put the tags into the field "toc_inactive" and deleted the tags afterwards with an action widget.
So the target is to bring back the complete branch by just one click if there is a new tiddler tagged with an inactive tiddler.

PMario

unread,
Feb 16, 2017, 10:19:30 AM2/16/17
to TiddlyWiki
On Thursday, February 16, 2017 at 3:58:01 PM UTC+1, PMario wrote:
01 Topictiddler
  010 Subtopic   <-  imo should not be shown, right?
  011 Subtopic
      0110 Subsubtopic
          01100 Subsubsubtopic
              Tiddler A
      0111 Subsubtopic
          01110       -> There is no Tiddler connected, so I want to toggle this tiddler

0111 has the "expand icon" because 01110 exists. ... _but_ .... 01110 has no "content tiddler" so it is basically empty. ... that's why you don't want to show the branch, if there is no leaves. .. where a leave is eg: Tiddler A.  right?

IMO there are  2 problems now. ..

 1) How do you know, that there are "hidden" branches, with no leaves, if you just see the TOC ... (I'm not a big fan of hidden info :)
 2) Branches are tiddlers. So they can contain content. ... So they may be leaves too ?

IMO there is no automagic way to detect it, if branches should be hidden. ... IMO you'll always need manual input ? 

I'm thinking about a possibility to have a similar mechanism than "toc-link:no" feature. It may be a "toc-expand:no", which would affect the "expandable >" icon. It would be suppressed. The problem now is: If you already suppressed lower branches you'd still have to enable them too :/

... hmmm

-m





PMario

unread,
Feb 16, 2017, 10:28:07 AM2/16/17
to TiddlyWiki
On Thursday, February 16, 2017 at 4:19:30 PM UTC+1, PMario wrote:
I'm thinking about a possibility to have a similar mechanism than "toc-link:no" feature. It may be a "toc-expand:no", which would affect the "expandable >" icon. It would be suppressed. The problem now is: If you already suppressed lower branches you'd still have to enable them too :/

It actually would need to be a "toc-hidden:yes". So all lower-branches and the "toc-hidden" branch are not shown anymore.

BUT

The branch-root eg: 01 Topictiddler  would need to show something like this.


01 Topictiddler (...) which would indicate, that there are "hidden" branches. And it would need a simple UI to enable the in a fast way.

01 Topictiddler is just a link and  (...) will open the new UI to enable branches.

what do you think?
-m

       


PMario

unread,
Feb 16, 2017, 10:40:53 AM2/16/17
to TiddlyWiki
On Thursday, February 16, 2017 at 4:16:21 PM UTC+1, The Bo wrote:
Yes, exactly!
Right now every empty branch is already not visible because I put the tags into the field "toc_inactive" and deleted the tags afterwards with an action widget.
So the target is to bring back the complete branch by just one click if there is a new tiddler tagged with an inactive tiddler.

I do understand. But with this workflow you kind of "destroy" the wonderful TW tagging mechanism. .. That's sad.
 
Have you seen my: tocP - Parent Based TOC plugin?

I did include a simple "editors-UI" which adds "new xx" buttons at the end of the toc-link. Which makes it simple to add new tiddlers. ... I'm imaging a similar UI for your usecase, which makes it fast and simple to enable and disable branches. So there would be no need to remove and add tags. It's just the visual representation of the structure, that is modified and not the "valuable" content.

-m

Mark S.

unread,
Feb 16, 2017, 3:54:45 PM2/16/17
to TiddlyWiki
Doesn't the "or" (aka pipe, "|") work in regular expressions? So you could test for all 4 patterns in one list filter.

Good luck!
Mark

The Bo

unread,
Feb 17, 2017, 9:05:03 AM2/17/17
to TiddlyWiki
Hey Mario,

thanks for your suggestions and I will have a look at your plugin. Yes it's a bit sad but it was the best workaround I could find so far. ;-)

@Mark
That won't work because I use the !is[tag] filter. For the example in my second post the "toggle" for the tiddler "01110" would work with one click. But the tiddler "0111" is used as a tag at that moment.
In my usecase I would need some sort of a chain.
Reply all
Reply to author
Forward
0 new messages