Message to appear (or modal) when a filter evaluates to true

Hi,

I’ve managed to cobble this together:

<% if [tag[test]get[f1]sum[]compare:number:gt[10]then[true]] +[match[true]] %>
Hooray!
<% endif %>

which is then transcluded in a tiddler tagged with $:/tags/AboveStory, so that when the filter is true, the message appears above the story river.

Even better would be for a modal window to appear when the filter is true.

Would this be hard to implement?

Thanks
Jon

Its not hard but it requires action widgets, you need to identify a trigger, Typicaly a button, simply being displayed is not enought.

If not placed behind a trigger it would just keep occuring.

Yes, it’s the result of the filter that I want to act as the trigger

When? Is then my question?

I am aware of some workarounds here however I would suggest finding a place on the tiddlywiki page where you can display this result of the filter and thus do not require a trigger is best. You could have an icon appear that someone clicks that then sends a message or opens a modal.

  • This I believe is based on a miss conception, It like saying “I want arithmetic to trigger actions”.
  • When in fact you want a particular result to trigger an action.
  • But when an actions can occur repeatedly you must either determine a point in time or condition of this to happen or it would happen forever.

When? Is then my question?

When the filter evaluates to true.

In my initial example, I’ve managed to get a message to appear when the condition is met.

I was just wondering if this could be extended using a modal window where the trigger would be the result of the filter.

It might not be possible - just exploring.

It can but let us use your terms “When the filter evaluates to true”. But it will continue to be true.

  • To identify a trigger you need a change, eg when the filter FIRST evaluates to be true.
  • Tiddlywiki is going to evaluate that filter every time the it needs to, to display the on screen.

The filter is actually a weekly total which varies and I want the action to be when the total is greater than x.

This actually works in my initial example,

That is what I recommend, the problem is if instead you use an alert or modal you need to choose when and how many times not just “if then display” as you do now

What you have there is conditional display of content. There is not trigger there.

That content is no different than CSS styling (or TW wikitext formatting).

As per “ActionWidgets”:

Action widgets are a special type of widget that have no visual appearance but perform an action when triggered (such as sending a message, navigating to a tiddler, or changing the value of a tiddler). Action widgets are used in association with other widgets that trigger those actions (for example, the ButtonWidget).

Action widgets require a user to do something (like click a button). However, there are other kinds of events that can trigger actions (like opening a modal window, for example): StartupActions or actions triggered by a timer (like this.)

1 Like

OK, thanks for the clarification.

Hi @Jon Note that there is a Filtered Actions proposal pending on GitHub that would allow to do what you have in mind: Introduce global "Filtered Actions" that are invoked when a filter evaluates to a non-empty result by Jermolene · Pull Request #7999 · Jermolene/TiddlyWiki5 · GitHub

1 Like

Excellent! Thanks, I’ll look forward to that (although I note that Jeremy thinks it’s “potentially highly dangerous” :open_mouth:)

Yeah, I totally agree. That in and of itself is enough for me to drop TiddlyWiki going forward.

Remember like all “improvements” to tiddlywiki, they will not manifest unless it is part of the core or you intentionally code the new feature in in TiddlyWiki Script. In the empty.html for example most of the features are just dormant. You would not know they exist unless you want them to.

Just in case I’m not expressing myself clearly…

There have always been a bunch of features in TiddlyWiki that I’ve never used and I’ve also never cared about their mere existence in the core.

Then there are features added to the core that I won’t use and their mere existence in the core bothers me.

This particular feature, if and when it does appear in the core, it bothers me enough that I won’t use any version of TiddlyWiki that has the specific feature. Maybe my feelings about it can evolve, but I’m heavily “oh hell no” right now.

All other features added after TW5.2.3: I dislike them enough that I won’t use those versions of TiddlyWiki. However, should a new version of TiddlyWiki include a “killer feature” that I cannot live without, I might find myself able to tolerate the presence of the other particular features.

Surprisingly, sticking with TW 5.2.3 has helped me find this forum much easier to manage, because I can more easily ignore the majority of the posts here, so cognitive win (I.e. less cognitive load, I.e. less over-stimulation) for me. Always look on the bright, si-ide of life …

1 Like

I think, that’s the right approach. You can implement some UI, that can get rid of that message, if you do not need it anymore.

The problem with automatic triggers is, that they can be triggered very often and controlling it predictably can be tricky.

1 Like