enhancement
major
minor
major
minor
minor
#29872
TL Views: the min/max/step of a number input (slider) are fixed in the configuration and cannot come from a channel or expression
tl-layout-view 8.0.0-alpha10, NumberInputControlProvider.Config (min, max, step).
Problem
The range of a number input - and of its slider display - is a fixed number in the view configuration. A view whose range depends on the data cannot express it: no channel, no TL-Script expression can set min, max or step.
In E-Home the group monitor's send form picks the input by the datapoint type of the selected address; the range follows the type (DPT 5.001 0-100 %, DPT 5.010 0-255, DPT 5.003 0-360, DPT 5.006 0-254). The server computes the range into a channel (target['min'], target['max'], target['unit']), but the slider cannot use it.
Reproduction
<channels> <channel name="target"/> <!-- a dictionary with min/max --> <channel name="value"/> </channels> ... <value-input type="tl.core:Double" value="value"> <input-control class="com.top_logic.layout.view.form.NumberInputControlProvider" min="0" max="100"/> </value-input>
There is no way to write max as target -> $target['max'].
Expected
min, max and step (and a unit for the label) can be bound to a channel or given as a TL-Script expression over channels, re-evaluated when the channel changes.
Workaround in E-Home
Two fixed slider kinds (percent 0-100 and scale 0-255) in projects/monitor.view.xml; DPT 5.003 and 5.006 keep the plain number field. Recorded in doc/tl-todo.md.
Lösung
The number input control declares inputs like a command (#29781, NamedInputs): the value of each named channel is an implicit variable of the control's TL-Script expressions. min, max and step become TL-Script expressions, and a new unit expression gives the text appended to the value, min and max labels of the slider ("12,5 %"). A literal number is still a valid expression, so every existing configuration keeps working unchanged.
<value-input type="tl.core:Double" value="value"> <input-control class="com.top_logic.layout.view.form.NumberInputControlProvider" display="slider" inputs="target" min="$target['min']" max="$target['max']" unit="$target['unit']"/> </value-input>
The expressions are evaluated again whenever one of the input channels changes, and the slider receives the new range, step and labels (ReactSliderControl re-sets its range at runtime; the client slider is props-driven and needs no change). The typed number input (display="input") ignores range and unit as before.
Validation: a configuration without inputs is evaluated once when the control provider is instantiated, and an unusable range (min not below max, step not above zero, missing bound of a slider) is a configuration error as before. With inputs, an unusable range at runtime - for instance while the channel is still empty - renders the slider disabled until the inputs yield a usable range. min and max remain mandatory for a slider.
Also fixed on the way: a select control (ReactDropdownSelectControl, dropdown, chips, segments, radio) matched its value against its options by object identity. A value equal to an option but not the same instance - a string a channel init writes, a number parsed from a configuration - was displayed as if no option were selected. Options are now matched by equality, like everywhere else in the control.
The styling demo of tl-demo-react shows a slider whose range and unit follow a segmented choice of datapoint kinds (percent 0-100 %, scale 0-255, angle 0-360 °) through derived channels; the kind is preselected through the channel's init.