Last active
February 6, 2018 20:19
-
-
Save dkorenblyum/766e06e4b424ce3d0efd6bc6db208160 to your computer and use it in GitHub Desktop.
New Twiddle
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({ | |
}); |
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: { | |
setChildren(parentNode) { | |
let children = this.get('getChildNodes')(parentNode); | |
this.set('children', children); | |
} | |
} | |
}); |
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) { | |
let nodes = this.get('nodes'); | |
return nodes.filter((node => { | |
return node.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