UI Controls¶
In an interactive product configuration session, the user interface (UI) should dynamically adapt its options based on the current configuration state. To facilitate this, the COOM language includes features that manage UI elements effectively, assuming the UI is designed to follow runtime instructions. This capability ensures that as users modify their configurations, the UI updates immediately to reflect relevant options, enhancing usability and streamlining the configuration process.
Hiding Elements¶
Using the keyword hide in a behavior block allows to hide certain features from the UI.
product {
Color color
...
bool withCarrier
Carrier carrier
}
behavior {
condition withCarrier = false
hide carrier
}
The shown behavior states that the field carrier should be hidden, if false is selected for the element withCarrier in the configuration session.
Note that you can either hide single terminal features, such as carrier.color or entire sub-trees of the hierarchy if structure features are hidden, like in the carrier in this example.
In some situations, hidden features need to reappear on screen, after the configuration state has changed again.
Note that in this declarative language, no show directive is required as the features will reappear automatically when the precondition of the hide directive is not fulfilled any more.
Hiding Options of an Enumeration¶
While hiding a feature removes the whole element from the UI, you sometimes want to keep an
enumeration feature visible but restrict which options of it are visible.
For example, when options are always blocked under certain conditions, it's helpful to not show them in the first place.
This is achieved by adding one or more option names after the feature in a hide directive.
behavior {
condition withCarrier = true
hide color red green
}
The shown behavior states that the options red and green of the enumeration feature color
should be hidden from selection, if true is selected for withCarrier. The color feature itself
remains visible, and the user can still choose between the remaining options blue and black.
A few rules apply to hiding options:
- The directive only works on features of an enumeration type; the listed names must be options of that enumeration.
- At least one option must be given, and you cannot hide all options of an enumeration.
- Unlike feature visibilities, option visibilities have no
readonly/readwritedirectives and no priority, they can only hide options.
As with hiding features, no show directive is required: the options reappear automatically once
the precondition of the hide directive is no longer fulfilled.
Note that hiding an option only affects its visibility in the UI; it does not remove the option from the solution space.
If an option must never be chosen under certain conditions, add a corresponding require in addition to hiding it.
Readonly for Element Values¶
The keyword readonly renders a feature unmodifiable, ensuring that users cannot alter its value.
In smart configuration systems, conflicting choices are preemptively filtered out, diminishing the necessity for the readonly attribute in many cases.
Consequently, the use of readonly is generally reserved for specific scenarios, such as displaying numerical calculations that must remain visible but uneditable, ensuring clarity and accuracy in user interactions.
structure Weight {
num wheelWeight
num frameWeight
num totalWeight
}
behavior Weight {
imply totalWeight = (wheelWeight * 2) + frameWeight
// set totalWeight to readonly as the user should not change this value
readonly totalWeight
}
The example illustrates readonly for the element totalWeight, since we do not want this element to be changed by the user.