enhancement
major
major
minor
#29809
TL Views: a <value-input type="tl.core:Binary"> shows the file name as text instead of the binary field (no upload, no download)
tl-layout-view 8.0.0-alpha10, ValueInputElement, FieldControlService.createFieldControl(ReactContext, TLType, FieldSpec, FieldModel, ...).
Problem
A <value-input> over a channel holding BinaryData with type="tl.core:Binary" does not get the control of a binary value (BinaryControlProvider / ReactBinaryFieldControl: upload in edit mode, download link in view mode). The type is not mapped (byType finds nothing for tl.core:Binary), and the fallback FieldControlRegistry builds a text display, so the dialog shows only the file name as plain text (<span class="tl-field-value__text">Test.knxproj</span>), without a download button.
Reproduction
A command whose action returns a BinaryData and opens a dialog with it:
<open-dialog bind-input-to="file" dialog-view="export.view.xml"/>
export.view.xml:
<channels><channel name="file"/></channels> ... <fields> <value-input readonly="true" type="tl.core:Binary" value="file"> <label><en>File</en></label> </value-input> </fields>
Shows "File: Test.knxproj" as text, no download.
Expected
tl.core:Binary resolves to BinaryControlProvider by type, as a <field> of a binary attribute does: in a read-only input a download link, in an editable one an upload.
Workaround in E-Home
projects/export-knxproj.view.xml names the control explicitly: <input-control class="com.top_logic.layout.view.form.BinaryControlProvider"/>. With it, the download works (the dialog of the .knxproj export).
Cause
The datatype tl.core:Binary declares BinaryDataSource as the application type of its storage mapping, so the field specification of a binary value carries that value type. The FieldControlRegistry (tl-layout-react) registers the binary control for BinaryData, a subtype of BinaryDataSource; its lookup walks the supertypes of the value type only, finds nothing and falls back to the text display. A <field> of a binary attribute without an <input-control> annotation takes the same path; the React demo (demo.react:Demo#image) carried the same workaround as E-Home.
Lösung
- FieldControlRegistry registers the binary control for BinaryDataSource, the application type of tl.core:Binary; the lookup by supertype covers BinaryData values as well.
- ReactBinaryFieldControl accepts any BinaryDataSource as its value and converts it to BinaryData for the download.
- TestFieldControlRegistry checks that a BinaryDataSource and a BinaryData value resolve to the binary control.
- React demo (tl-demo-react): the PDF demo shows the data of the selected document in a read-only <value-input type="tl.core:Binary"> (download link); the <input-control> workaround on demo.react:Demo#image is removed, so the plain <field> of a binary attribute exercises the type-based resolution.
BinaryControlProvider remains available for naming the control explicitly.