Forked from chrishowes/controllers.application.js
Created
September 28, 2016 14:33
-
-
Save thestrabusiness/68d8cb4d6c7f729942c53bc1bd095382 to your computer and use it in GitHub Desktop.
New Twiddle
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'VisitDays' | |
}); |
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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
firstName: attr("string"), | |
lastName: attr("string"), | |
visits: belongsTo("visit") | |
}); |
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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
name: attr("string"), | |
users: hasMany("user"), | |
}); |
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
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('visits'); | |
this.route('visit', { path: '/visit/:visit_id'}); | |
this.route('users'); | |
}); | |
export default Router; |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
beforeModel() { | |
var user1 = this.store.createRecord("user", { | |
firstName: "First", | |
lastName: "User", | |
}); | |
var user2 = this.store.createRecord("user", { | |
firstName: "Second", | |
lastName: "User", | |
}); | |
var user3 = this.store.createRecord("user", { | |
firstName: "Third", | |
lastName: "User", | |
}); | |
var user4 = this.store.createRecord("user", { | |
firstName: "Fourth", | |
lastName: "User", | |
}); | |
var user5 = this.store.createRecord("user", { | |
firstName: "Fifth", | |
lastName: "User", | |
}); | |
var visit1 = this.store.createRecord("visit", { | |
id: 1, | |
name: "Morning Visit", | |
users: [user1, user2, user3] | |
}); | |
var visit2 = this.store.createRecord("visit", { | |
id: 2, | |
name: "Afternoon Visit", | |
users: [user4, user5] | |
}); | |
}, | |
redirect: function () { | |
this.transitionTo('visits'); | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model: function(params) { | |
return this.get('store').findRecord('visit', params.visit_id); | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.get('store').findAll('visit') | |
} | |
}); |
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
{ | |
"version": "0.10.5", | |
"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.8.0", | |
"ember-data": "2.8.0", | |
"ember-template-compiler": "2.8.0", | |
"ember-testing": "2.8.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment