Skip to content

Instantly share code, notes, and snippets.

@hashg
Created March 23, 2013 05:13
Show Gist options
  • Save hashg/5226546 to your computer and use it in GitHub Desktop.
Save hashg/5226546 to your computer and use it in GitHub Desktop.
{
"projects": [
{
"updated": null,
"name": "USA",
"created": null,
"is_active": true,
"persons": [
{
"updated": null,
"user_id": "HGOWDA",
"name": "H Gowda",
"created": null,
"passwd": null,
"is_active": true,
"id": "1",
"project_id": "1",
"email": "h.gowda@temp.com"
},
{
"updated": null,
"user_id": "JECHEN",
"name": "J Chen",
"created": null,
"passwd": null,
"is_active": true,
"id": "2",
"project_id": "1",
"email": "j.chen@temp.com"
}
],
"iterations": [
{
"updated": null,
"name": "iteration 001",
"created": null,
"is_active": true,
"project_id": "1",
"id": "1"
},
{
"updated": null,
"name": "iteration 002",
"created": null,
"is_active": true,
"project_id": "1",
"id": "2"
},
{
"updated": null,
"name": "iteration 003",
"created": null,
"is_active": true,
"project_id": "1",
"id": "3"
}
],
"id": "1",
"desc": "Team USA"
},
{
"updated": null,
"name": "EMEA",
"created": null,
"is_active": true,
"persons": [
{
"updated": null,
"user_id": "MINMA",
"name": "Ming Ma",
"created": null,
"passwd": null,
"is_active": true,
"id": "3",
"project_id": "2",
"email": "ming.ma@temp.com"
},
{
"updated": null,
"user_id": "JPATARD",
"name": "J Patard",
"created": null,
"passwd": null,
"is_active": true,
"id": "4",
"project_id": "2",
"email": "j.patard@temp.com"
}
],
"iterations": [
{
"updated": null,
"name": "iteration 004",
"created": null,
"is_active": true,
"project_id": "2",
"id": "4"
},
{
"updated": null,
"name": "iteration 005",
"created": null,
"is_active": true,
"project_id": "2",
"id": "5"
},
{
"updated": null,
"name": "iteration 006",
"created": null,
"is_active": true,
"project_id": "2",
"id": "6"
}
],
"id": "2",
"desc": "Team EMEA"
},
{
"updated": null,
"name": "India",
"created": null,
"is_active": true,
"persons": [
{
"updated": null,
"user_id": "KAMBLE",
"name": "K Amble",
"created": null,
"passwd": null,
"is_active": true,
"id": "5",
"project_id": "3",
"email": "k.amble@temp.com"
},
{
"updated": null,
"user_id": "ANANDA",
"name": "Ananada R",
"created": null,
"passwd": null,
"is_active": true,
"id": "6",
"project_id": "3",
"email": "ananda.r@temp.com"
}
],
"iterations": [
{
"updated": null,
"name": "iteration 007",
"created": null,
"is_active": true,
"project_id": "3",
"id": "7"
},
{
"updated": null,
"name": "iteration 008",
"created": null,
"is_active": true,
"project_id": "3",
"id": "8"
},
{
"updated": null,
"name": "iteration 009",
"created": null,
"is_active": true,
"project_id": "3",
"id": "9"
}
],
"id": "3",
"desc": "Team India"
}
]
}
(function(){
window.Scrums = Ember.Application.createWithMixins({
LOG_TRANSITIONS: true,
init: function () {
this.deferReadiness();
this._super();
}
});
Scrums.Router.map(function () {
this.resource('projects');
this.resource('project', {path: '/projects/:project_id'});
this.resource('iteration', {path: '/iterations/:iteration_id'});
this.resource('story', {path: '/storys/:story_id'});
this.resource('task', {path: '/task/:task_id'});
});
Scrums.IndexRoute = Ember.Route.extend({
redirect: function () {
this.transitionTo('projects');
}
});
Scrums.ProjectsRoute = Ember.Route.extend({
model: function () {
return Scrums.Project.find();
}
});
Scrums.advanceReadiness();
})();
<script type="text/x-handlebars" data-template-name="application">
<div class="container">
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="projects">
<h1>Projects Template</h1>
{{#each controller}}
<div>
{{#linkTo project this}}{{name}}{{/linkTo}}
</div>
{{/each}}
</script>
<script type="text/x-handlebars" data-template-name="project">
<h1>Project Template</h1>
<span>{{name}}</span>
{{#each iterations}}
<div>
{{#linkTo iteration this}}{{name}}{{/linkTo}}
</div>
{{/each}}
</script>
Scrums.Store = DS.Store.extend({
revision: 12,
adapter: DS.RESTAdapter.create({
namespace: 'api'
})
});
DS.RESTAdapter.map('Scrums.Project', {
iterations: { embedded: 'always' },
persons: { embedded: 'always' }
});
Scrums.Project = DS.Model.extend({
name: DS.attr('string'),
iterations: DS.hasMany('Scrums.Iteration',{embedded: 'always'}),
persons: DS.hasMany('Scrums.Person',{embedded: 'always'})
});
Scrums.Person = DS.Model.extend({
name: DS.attr('string'),
project_id: DS.attr('number'),
project: DS.belongsTo('Scrums.Project')
});
Scrums.Iteration = DS.Model.extend({
name: DS.attr('string'),
project_id: DS.attr('number'),
project: DS.belongsTo('Scrums.Project',{embedded: 'always'}),
storys: DS.hasMany('Scrums.Story', {embedded: 'always'})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment