Review main Merged

67650[TASK] Clean up Drag&Drop Handling in PageTree

Benni Mack CR +2 V +2 Expert +909 −923 updated 02/08/21, 07:36

Commit message

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).

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 13