enhancement
major
major
minor
#29805
TL Views: a <value-input> is declared like a model attribute (mandatory, annotations) - a mandatory enumeration input offers no "no value" option
A <value-input> (ValueInputElement, tl-layout-view 8.0.0-alpha10) builds an AbstractFieldModel / SimpleSelectFieldModel that is never mandatory, and the configuration has no option for it. An input of an enumeration type therefore always offers "no value" ("Kein Wert") next to the classifiers.
Reproduction
<value-input type="ehome.operational:InsertPosition" value="position"> <input-control class="com.top_logic.layout.view.form.SelectControlProvider" display="radio"/> </value-input>
shows the radio buttons "Kein Wert", "Im ausgewählten Element (am Ende)", "Nach dem ausgewählten Element".
Requested
mandatory="true" on <value-input> (as a field of a mandatory attribute behaves): no empty option for a selection, the mandatory check for other inputs, and the same for <field>`s of a mandatory attribute inside a `<fields> grid if they differ.
Workaround in E-Home
catalogs/create-structure.view.xml: the position choice is a derived channel with a reverse, so choosing "no value" falls back to the default position; the empty option stays visible.
Lösung
Mandatory is only one of the properties an attribute of a class carries. A <value-input> therefore describes its value with the vocabulary of a <property> in the model XML: type, mandatory, multiple and <annotations>.
- ValueInputElement.Config extends AttributeConfigBase (the <annotations> of a model attribute, TLAttributeAnnotation`s) and gains `mandatory="true".
- A mandatory input marks its field model mandatory. The field specification, the chrome (required marker) and every select display follow: the radio group offers no "no value" button, the dropdown no clear button, segments and chips cannot be un-selected.
- A mandatory input the user empties (text, number, date) writes the empty value to the channel like any other value, shows the mandatory error of the form validation ("Das Feld darf nicht leer sein.") at the field until a value is entered, and does not run its on-submit command on the empty value; the submit itself reports nothing else (no error toast).
- The <annotations> of the element are the annotation lookup of the field: <classification-display>, <boolean-display>, <multi-line>, <format> etc. act as on an attribute, with the annotations of the type as fallback. An <input-control> annotation is consulted by the type-based control resolution of FieldControlService (one implementation shared with the attribute path); the input-control property of the element still wins.
- A <field> of a mandatory attribute, inside a <fields> grid as well, already takes mandatory from the attribute; nothing changes there. In the React demo, demo.react:Demo#priority is mandatory now, so the form demos show such a field.
Out of scope: default values and constraint checks of the annotations - both need a TLStructuredTypePart and an object, which a channel value has not.
<value-input type="ehome.operational:InsertPosition" value="position" mandatory="true"> <annotations> <classification-display value="radio"/> </annotations> </value-input>
Demo: tl-demo-react, Demos → Gestaltung, last section "Ein Wert, deklariert wie ein Attribut" (mandatory and optional radio groups and dropdowns, a mandatory text with on-submit, a control chosen by annotation). Documentation: developer articles view-layer/basics and view-layer/forms.