I have created an action at Window-level, and attached an enabledRule to it. It doesn’t seem to fire to disable the attached button.
I’ve found that I can trigger then rule manually by calling
action.refreshState()
but I wondered if there is a case where the framework would trigger the rule itself for an action at window level. I was thinking that it should be triggered for any change inside the window it’s part of.
Hi,
Yes, you are right, enabledRule for screen-level actions are not used at the moment, this behavior is not implemented.
Feel free to vote the issue on the GitHub or post your requirements as comments.
Currently you can implement desired behavior manually in the screen controller with dataContainer or component event listeners.
Not sure how to vote to fix the problem, but it does seem very inconsistent. It works for dataContainers, but when you apply it anywhere else, it doesn’t work, without warning you that it just doesn’t work.
I think the correct behaviour should trigger the rule whenever an event is fired in the window, but that might cause quite a lot of overhead, or might be difficult to code in the framework (haven’t looked at the code in a while, so I’m guessing).
Going back to what I did to solve the problem: I called action.refreshstate() in the event listener for every component where the enableRule needed calling.
So how about adding an optional parameter to the annotation that would give a list of the components that need to be observed by the rule call? For example: