Code Monkey home page Code Monkey logo

ember-cli-tree's Introduction

Ember-cli-tree

simple tree UI component for Ember. No JQuery. Pure handlebars and recursion.

npm version Build Status

Installation

ember install ember-cli-tree

Usage

The only thing you need to care of is how your single tree node looks like. Here is an example tree object:

const treeHead = {
  label: '1',
  children: [
    {
      label: '2'
    },
    {
      label: '2',
      children: [
        {
          label: 3
        }
      ]
    }
  ]
}

Simple usage:

{{#ember-tree node=treeHead as |node isExpanded|}}
  {{#ember-tree/trigger-expand}}
    {{#if isExpanded}}
      -
    {{else}}
      +
    {{/if}}
  {{/ember-tree/trigger-expand}}
  {{node.label}}
{{/ember-tree}}

Component's API

  • eagerCreate - boolean, determines, how tree is rendered:
    1. if set to true, the whole tree is placed into DOM upon component's insertion (show/hide is implemented via display: none)
    2. if set to false, every node is inserted individually lazily upon parent's node expansion (show/hide is implemented via if helper) (Default: true)
  • childrenKey - String, the key of children attribute in tree node object (Default: 'children')
  • expandEvent - String, event, which causes expanding of node when triggered on ember-tree/trigger-expand component (Default: 'click')
  • showOnly - Number, the number of node's children shown by default (Default: undefined)
  • showOtherTextFmt - String (format string, see Ember.String.fmt for details), if showOnly is set, the value of this property is the value of link text, clicking on which makes hidden children to be shown, where 1st format parameter - # of children left (Default: 'Show Other %@')
  • expandAction - String, name of an action, which handles expansion of sub trees on top level. If defined, node.isExpanded have to be manually set, e. g.

See tests for more.

...
expandActionHander(node, isExpanded){
  // some custom handling, then
  Ember.set(node, 'isExpanded', isExpanded);
}
...

TODO list:

  • add drag and drop

Contribution

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

ember-cli-tree's People

Contributors

ember-tomster avatar kategengler avatar pavloo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.