-
-
Save dkorenblyum/614e43b2ce1e6326311ffb84c0e024c6 to your computer and use it in GitHub Desktop.
nested-list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
actions: { | |
expand(item) { | |
Ember.RSVP.resolve(this.get('expand')(item)).then((list) => { | |
this.set('nestedList', list); | |
}); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
init () { | |
this._super(...arguments); | |
this.set('nodes', [{ | |
"id" : 1, | |
"parent" : null, | |
"name" : "Root1" | |
}, | |
{ | |
"id" : 2, | |
"parent" : null, | |
"name" : "Root2" | |
}, | |
{ | |
"id" : 3, | |
"parent" : 2, | |
"name" : "Child2-3" | |
}, | |
{ | |
"id" : 4, | |
"parent" : 2, | |
"name" : "Child2-4" | |
}, | |
{ | |
"id" : 5, | |
"parent" : 1, | |
"name" : "Child1-5" | |
}, | |
{ | |
"id" : 6, | |
"parent" : 1, | |
"name" : "Child1-6" | |
}, | |
{ | |
"id" : 7, | |
"parent" : 6, | |
"name" : "Child6-7" | |
}, { | |
"id" : 8, | |
"parent" : 6, | |
"name" : "Child6-8" | |
}] | |
); | |
let rootNodes = this.get('nodes').filter((node) => { | |
return node.parent ? false : true | |
}) | |
this.set('rootNodes', rootNodes); | |
}, | |
actions : { | |
findChildren (parent) { | |
return this.get('nodes').filterBy('parent', parent.id); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.13.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment