The three switch-coordination rules
Example module: hellotypes, switchoneofmany/switchatmostone/switchany properties.
Several ElementBool elements within the same property can be coordinated with each other like radio buttons or independent checkboxes, via "rule" in the property’s JSON:
rule | Behavior |
|---|---|
0 — OneOfMany | Exactly one true at a time (radio). Setting an element to true resets all the others to false. Setting it back to false directly is refused — another one must be chosen instead. |
1 — AtMostOne | Zero or one true (optional radio). Same behavior, except it can also be directly deselected. |
2 — Any (default) | No constraint, independent checkboxes. |
"switchoneofmany": {
"permission": 2,
"rule": 0,
"e": {
"calibrate": { "type": "bool", "directedit": true },
"guide": { "type": "bool", "directedit": true },
"stop": { "type": "bool", "directedit": true }
}
}Fully declarative: the actual enforcement of the rule lives in the framework itself, triggered by any write to one of the elements — no code to write in the module for it to work, only to set a consistent initial state if needed.