Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Move tree structure into a model #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Move tree structure into a model #8

wants to merge 7 commits into from

Conversation

omghax
Copy link
Contributor

@omghax omghax commented Nov 21, 2016

Previously we had been relying on Ember's rendering process to build up a tree of components for us. This proved brittle since there were cases where we needed to know about a node's children in order to render the node itself (see #5 and #7).

This PR moves the node logic into a separate TreeNode class, sidestepping the problem.

  • Update README
  • Figure out how to handle changing expanded in a way that's compatible with "Data Down, Actions Up"

This removes the TreeNode mixin from the components, in favor of keeping
the actual tree structure in a separate model. This removes our
dependence on Ember's render process, which has changed quite a bit
since this addon was first written. This also allows us to fix the
deprecation warnings (and later errors) related to setting a property
during `didInsertElement`.
The `ivy-tree` component now defines `groupComponent` and
`treeitemComponent` properties which can be set to a curried
`{{component}}` instance, or the name of a component to use as the group
and treeitem components, respectively.
In the spirit of Data Down, Actions Up, we now expose actions for
collapsing and expanding a node. These actions are called with the node
as an argument. In the simplest case, you should call `node.collapse()`
or `node.expand()` from your action.
This means "activate" is now "activateNode", "collapse" is now
"collapseNode", and "expand" is now "expandNode".
Previously, a POJO `model` property would be passed in to `{{ivy-tree}}`
and the component would then build an in-memory tree of nodes. Now the
responsibility for building the tree is pushed out to the caller, and a
`buildTree` function is exposed for this purpose. This is a bit nicer
since it makes the tree nodes accessible to the caller, in case they
want to, for instance, expand or collapse nodes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant