a filter question: two fields has value then NO else YES

61 views
Skip to first unread message

Mohammad Rahmani

unread,
Mar 20, 2021, 12:30:31 PM3/20/21
to tiddl...@googlegroups.com
Question: There is a tiddler say myTiddler, a button shall be visible if and only if both fields of fone and ftwo  have non empty values

I know this can be done using two $list widgets but I am looking for a simpler more semantic solution!


Pseudo code

<$vars disabled={{{ if [[myTiddler]get[fone]!is[blank]]  AND  [[myTiddler]get[fone]!is[blank]] then NO else YES }}} >

<$button disabled=<<disabled>> > Create </$button>

</$vars>


What do you think?


Best wishes
Mohammad

Mohammad Rahmani

unread,
Mar 20, 2021, 12:45:23 PM3/20/21
to tiddl...@googlegroups.com
One solution I came up with is as below.

Note here the two fields are name (fone) and colorsheme (ftwo)

\define tmpTid() myTiddler

<$vars   disabled={{{[<tmpTid>get[name]!is[blank]then[no]else[yes]] :intersection[<tmpTid>get[colorscheme]!is[blank]then[no]else[yes]] ~[[yes]]}}} >
<$button actions=<<newPalette>> disabled=<<disabled>>>Create</$button> 
</$vars>


This is an ugly solution! I am looking for a simpler, more semantic and easy to follow!

Note ii: the button is working if two fields are not empty at the same time!


Best wishes
Mohammad

Eric Shulman

unread,
Mar 20, 2021, 1:49:34 PM3/20/21
to TiddlyWiki
On Saturday, March 20, 2021 at 9:45:23 AM UTC-7 Mohammad wrote:
<$vars   disabled={{{[<tmpTid>get[name]!is[blank]then[no]else[yes]] :intersection[<tmpTid>get[colorscheme]!is[blank]then[no]else[yes]] ~[[yes]]}}} >
This is an ugly solution! I am looking for a simpler, more semantic and easy to follow!

You can use the "has[...]" filter which, by default, looks for non-empty field values.
You can also combine both field tests into one filter run.

Thus:
<$vars disabled={{{ [<tmpTid>has[name]has[colorscheme]then[no]else[yes]] }}}>

 enjoy,
-e

Mohammad Rahmani

unread,
Mar 20, 2021, 2:24:13 PM3/20/21
to tiddl...@googlegroups.com
Hi Eric,

Wonderful! Works like a charm!

 
 enjoy,
-e

Thank you

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f77b6d4b-cf1c-43a7-ab89-e79a0e139731n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages