-
-
Save frekw/a159097b0df22d7dde9f to your computer and use it in GitHub Desktop.
This file contains 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
sc_require('models/project'); | |
MyApp.Project.FIXTURES = [ | |
{ | |
guid:1, | |
name: "Foo" | |
}, | |
{ | |
guid:2, | |
name:"Bar" | |
} | |
]; |
This file contains 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
MyApp.main = function main(){ | |
var projects = MyApp.store.find(MyApp.Project); | |
MyApp.projectsController.set('content', projects); | |
} | |
MyApp.projectsController = SC.ArrayController.create({}); |
This file contains 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
MyApp.mainPage = SC.Page.design({ | |
// snip.. | |
mainPane: SC.MainPane.design({ | |
childViews: [SourceListView.design({ | |
contentValueKey: "name", | |
contentBinding: "MyApp.sourcesController.arrangedObjects", | |
selectionBinding: "MyApp.sourcesController.selection" | |
})] | |
}) | |
// snip.. | |
}) |
This file contains 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
MyApp.Project = SC.Record.extend({ | |
name: SC.Record.attr(String) | |
}) |
This file contains 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
sc_require('controllers/projects.js') | |
MyApp.sourcesController = SC.TreeController.create({ | |
content: null, | |
projects:'', | |
projectsBinding: 'MyApp.projectsController.content', | |
buildSources: function(){ | |
var p = this.get('projects'), | |
projectsSource; | |
if(!p) return; | |
projectsSource = this.buildProjectsSource(p); | |
console.log(projectsSource); | |
var sources = SC.Object.create({ | |
treeItemIsExpanded: YES, | |
treeItemChildren: [SC.Object.create({ | |
treeItemIsExpanded: YES, | |
group: true, | |
name: "Projects", | |
treeItemChildren: projectsSource | |
})] | |
}); | |
this.set('content', sources); // watch the console explode as this causes an inifnite loop. | |
}.observes('projects'), | |
buildProjectsSource: function(projects){ | |
var ret = []; | |
for(var i = 0, len = projects.length(); i < len; i++) | |
ret.push(SC.Object.create({ | |
name: projects.objectAt(i).get('name') | |
})); | |
return ret; | |
} | |
}) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment