Dynamically change Snap's settings tab
- 5 years ago
The only dynamic functionality is enableIf, which you can attach to a property in the defineProperties method:
.enableIf("$.settings.locale.value == 'en'")
You can build compound conditions using the normal logical operators (&&, ||, !).
If locale had an expression toggle and you want to test whether it’s true or false, you would use “$.settings.locale.expression” in the expression. Unfortunately if the entry does contain an expression, you can’t actually test the result of evaluating that expression, since that would involve a call to the back end, which this doesn’t do. This is just testing the state of the UI controls in the browser. The way we deal with this current limitation in our snaps that use this feature is to enable a dependent property if the controlling property has a particular value and is not an expression, or it is an expression.
The term “enable” is a bit misleading because what it actually controls is visibility. When the condition is true, the control is visible, otherwise it’s hidden.