major
minor
major
minor
major
#26959
Drag&Drop: Generalization of the DropByExpression API
When configuring a tree- or table-like component in the application, you have the option to configure expressions for the drag-and-drop functionality.
The configured TLScript expressions specify whether a dragged object can be dropped at a specific location within the component and what should happen afterward.
Currently, the signature of the configured expressions is limited to a single dragged element. However, it is possible to drag and drop multiple objects simultaneously within the application. If this is the case, the configured expression is applied to each individual dragged object.
Improvement
The signature of the expressions 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. Furthermore, this allows for the formulation of more complex rules that can make a decision for the entire set of dragged objects, rather than treating the operation merely as a shortcut for many individual operations (some of which may be executed and others 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 ` must be adapted.
A semantically preserving rewriting temporarily stores 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();
}
or
handleDrop:
object -> reference -> foobar()
becomes
handleDrop:
draggedObjects -> reference -> {
handler = object -> reference -> foobar();
$draggedObjects.foreach(object-> $handler($object,$reference));
}
Test
No test. Refactoring.