• Benni Mack's avatar
    [TASK] Clean up Drag&Drop Handling in PageTree · 85c7264b
    Benni Mack authored and Georg Ringer's avatar Georg Ringer committed
    The PageTree components for the navigation area consists of:
    * PageTreeElement (container for rendering the navigation area w. toolbar + dragdrop + tree)
    * PageTreeToolbar (uses DnD for creating new items)
    * PageTree (JS, subclass of SvgTree)
    * PageTreeDragDrop
    
    This patch aims to rework the "PageTreeDragDrop" javascript file
    by moving separate logic into separate classes (as much as possible)
    and into a more stable API, being a first part.
    
    PageTreeDragDrop is a mixed code class currently,
    and is now split up in various separate classes:
    * DragDropHandler (interface)
    * ToolbarDragHandler -> used as the Toolbar Draggable Handler for new pages
    * PageTreeNodeDragHandler => used for moving/copying and deleting existing pages/nodes
    * PageTreeDragDrop now acts as a simple wrapper for d3-drag but still has some shared state
    
    For Future Reference:
    It is still up to decide on how to further decouple the code.
    
    Idea 1: Putting the d3-drag initialization into the right
    place and avoiding cross-dependencies. In general "initializeDragForNode"
    would also be handled via events, and all options / settings would be
    moved into the PageTreeDragDrop class.
    
    Ideally the PageTreeDragDrop contains the status of the
    current drag+drop action (position, node etc), so the PageTree
    would not know of anything itself.
    
    Idea 2: Another possibility is to use the current "PageTreeDragDrop"
    as a generic "TreeDragDropManager" because it does not
    contain any Page-Tree specific code anymore, but could be carried
    on later-on.
    
    The current change is already a good step as it moves all code
    to TypeScript and minimizes injection via constructors (except
    for the Tree itself).
    
    Resolves: #93446
    Releases: master
    Change-Id: Ibd7a067c1e6a821b138a8cc2971ec8133392b600
    Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67650
    
    
    Tested-by: default avatarTYPO3com <noreply@typo3.com>
    Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
    Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
    Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
    Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
    85c7264b