Entity Master DSL: provide support for automatic identification of property editor types
Description
Existing Entity Master DSL requires specification of a property editor after adding a property. The original intent of this was to make the decision of choosing a property editor explicit (i.e., more conscious) and to support a path for customisation, such as specify property actions, value matcher, etc.
Using Entity Master DSL for some time now with different software engineers on a variety of projects suggests that stronger validation and automation is required.
-
[ ] 1. Stronger validation: It should not be possible to use incompatible property editor for a property of a given type. For example, currently it is possible to use
asSinglelineTextfor an entity-typed property or a date property or a composite key (e.g.RotableEo_.key()).asAutocompletercan be used as a date property too. This should not be permitted. -
[ ] 2. Automation: In the vast majority of cases it is possible to avoid the need to specify property editors, because they can be determined automatically based on the property type.
For example, call
.addProp(WorkOrder_.technician()).asAutocompleter()can be easily substituted with.addProp(WorkOrder_.technician()). It should still be possible to specify property editor explicitly to support customisations as currently and not to break existing codebases.Needless to say, that a property type is not only the type of the field, but also various annotations. For example, a property of type
Dateand annotation@TimeOnlyrepresents a "time type" andasTimePicker()is implied. Similar for@DateOnly.String-typed properties should assume
asSinglelineText()and it would be up for a developer to specifyasMultilineText().
Implementation remarks
- Erroneous definitions should be prevented early runtime during server start. Because otherwise the client-side error is not really helpful (which should be improved too, if possible):
Uncaught Unsupported conversion exception: the conversion for value [[object Object]] is unsupported at this stage. Value typeof === object. Error happened in: https://tgdev.com/resources/master/actions/tg-action.js at Ln: 541, Co: 25
{"message":"Unsupported conversion exception: the conversion for value [[object Object]] is unsupported at this stage. Value typeof === object."}
Please note, that composite keys are not supported in any editor [yet?]. As part of this issue, it should also be investigated the practicality for using composite key as a whole in editors. Now we can add some entity-typed composite property asAutocompleter(), except this aka "itself" (see #2113 for more rigorous and complete editing proposal). But what would happen if we add .key() of that property (including this.key() aka "itself.key()")? If we consider this API usage practical, perhaps by providing only readonly view, then separate issue needs to be added.
Expected outcome
More reliable and simple to use Entity Master DSL.