enhancement
major
minor
defect
critical
major
minor
major
#30062
Model editor of the React UI: instance browser and instance import of the selected type
Split off #30047 (administration views not yet ported, recorded during #29767). Related: #29108.
Context
The model editor of the React UI is contributed by tl-dev-tools as Administration → Model. The classic model editor additionally has an instance browser of the selected type (instanceBrowser.layout.xml) and an instance import (instanceUpload/dialog.layout.xml).
Feature
In the React model editor, a tab Instances next to the class diagram shows the instances of the selected class - for an abstract class the instances of all its concrete specializations. In edit mode the instances are edited in the table, rows are added and deleted. A new row of an abstract class asks which concrete type to create. The selected instances are exported as XML (*.objects.xml), the table as Excel, and a dialog imports instances from an XML file.
Editing the model itself (references, generalizations, diagram editing) is #30035, not part of this ticket.
Lösung
Row creation of abstract types (`<table row-edit>`, `<composition-table>`)
A create type stands for its concrete types (ModelAccessPolicy.concreteTypes): a concrete type for itself, an abstract one for its concrete specializations; an abstract type without concrete specialization offers no row creation. Only the types the current user may create are offered (in a persistent form object the check the save applies). With several types, the add command opens a menu at its button listing them by label; the chosen one is created. Before, an abstract create type (or a <composition-table> over a reference of abstract type) failed when a row was added.
- One add command for both tables (RowSetTableControl#getAddRowCommand()): the frameless row-editing <table> contributes it to the command scope of the form, the <composition-table> shows it in its toolbar. It is visible only while a type is offered.
- RowSetEditSession#createTypes() / #addRow(TLClass, Consumer).
- CommandTrigger (tl-layout-react): a ReactButtonControl announces its ID for the duration of its click, so that a command answering with a follow-up menu places it at the clicked button.
Row and create types computed from the inputs (`<table>`, `<tree-table>`)
types-expr and create-type-expr are TL-Script expressions over the table's inputs, the computed counterparts of types and create-type with the same meaning; each pair is mutually exclusive (configuration error). They are evaluated when the control is built (inside a <switch rebuild="true"> once per input value). The personalization key of the table is formed from the computed types (also together with a configured personalization-key), so the column choice is kept per type.
Download of exported objects
- <download/> accepts every file (BinaryDataSource), so the result of instanceExport(...) can be downloaded; before, it reported "... is not a file".
- The default name of an instance export uses a 24-hour clock (yyyy-MM-dd_HH-mm-ss).
Model editor (`tl-dev-tools`)
- The center pane is a tab bar Diagram / Instances.
- Instances: row-editing table over all($type) with types-expr / create-type-expr = the selected class, removal deletes on save; commands Export instances (XML of the selected rows, instanceExport), Excel export, Import instances.
- Import dialog (admin/model/import-instances.view.xml): XML file field, instanceImport($file, false, $type) in a transaction; the table reads its rows again afterwards.
- The XML export follows composition references; objects in other references need an <instance-resolver> annotation on their type (or the export is refused with a message naming the reference), as in the classic instance browser.
Verification
tl-demo-react (/view/, root / root1234), Administration → Model, select a type, tab Instances. Abstract class with instances: module demo.charts, class Transaktion. Abstract create type in a composition table: Projects → P2 → Deliverables, panel Edit deliverables.