the-teacher / the_sortable_tree

Nested Set + Drag&Drop GUI. Very fast! Best render helper! 2000 nodes/sec. Ready for rails 4
MIT License
558 stars 127 forks source link

Fixes #84 #85

Closed patrick-nits closed 8 years ago

patrick-nits commented 8 years ago

Considering the setup mentioned in the beginning, this PR determines the roots to be rendered correctly.

XoR for node_ids and parent_ids is used to determine all Node#id which are either a root or a leaf. Then, opts[:boost] is used to check which of the nodes (which are either root or leaf) are root nodes for the tree (or sub tree)

This leverages the previously built opts[:boost] ID-Hash, where each Node is mapped to his corresponding parent_id.

A leaf will not be present in this hash, because it will never act as a parent.