Major
Detail
Major
Detail
Major
#26959
Drag&Drop: Generalization of the DropByExpression API
If you configure a tree-like or table-like component in the application, then you have the possibility to configure expressions for the drag and drop functionality.
The configured TLScript expressions specify whether a dragged object can be dropped at a certain point in the component and what should happen afterwards.
Currently, the signature of the configured expressions is limited to a single dragged item. However, it is possible to drag and drop multiple objects at the same time in the application. If this is the case, then the configured expression will be applied to each individual dragged item.
Improvement
The signature of the expression should be generalized to a set of dragged elements. This has the advantage that the expression is evaluated only once per drag and drop operation. It also allows more complex rules to be formulated that can make a decision for the entire set of dragged items, rather than just treating the operation like a short-cut for many individual operations (some of which can be performed and some of which may not).
Code migration
Since the signature of the configured expressions for tl:TableDropTargetByExpression and tl:TreeDropTargetByExpression has changed, the expressions for canDrop and handleDrop need to be adjusted.
A semantic-preserving rewrite caches the existing TLScript function and applies it to all objects:
canDrop:
object -> reference -> foobar()
becomes
canDrop:
draggedObjects -> reference -> { handler = object -> reference -> foobar(); $draggedObjects.filter(object-> !$handler($object,$reference)).isEmpty(); }
respectively.
handleDrop:
object -> reference -> foobar()
becomes
handleDrop:
draggedObjects -> reference -> { handler = object -> reference -> foobar(); $draggedObjects.foreach(object-> $handler($object,$reference)); }
Test
No test. Refactoring.