Last active
March 6, 2017 03:38
-
-
Save jmimi/5ef83018c9fdef3e57be5b12c7e3cd5e 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
import DS from 'ember-data'; | |
export default DS.RESTAdapter.extend({ | |
}); |
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: 'Ember Twiddle', | |
refinedTeams: Ember.computed.filter('model.[]', function(team){ | |
return !team.get('players').isAny('status', 'injured'); | |
}), | |
actions: { | |
loadData(){ | |
this.set('model', this.store.peekAll('team')); | |
} | |
} | |
}); |
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'), | |
"status": attr('string'), | |
"team": DS.belongsTo('team',{ | |
async: true | |
}) | |
}); |
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'), | |
"players": DS.hasMany('player',{ | |
async: true | |
}) | |
}); |
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({ | |
init(){ | |
this._super(...arguments); | |
const players = [ | |
{ | |
id: '1', | |
name: 'Player 1', | |
status: 'healthy', | |
team: '1' | |
}, | |
{ | |
id: '2', | |
name: 'Player 2', | |
status: 'healthy', | |
team: '1' | |
}, | |
{ | |
id: '3', | |
name: 'Player 3', | |
status: 'injured', | |
team: '1' | |
}, | |
{ | |
id: '4', | |
name: 'Player 4', | |
status: 'healthy', | |
team: '2' | |
}, | |
{ | |
id: '5', | |
name: 'Player 5', | |
status: 'healthy', | |
team: '2' | |
} | |
]; | |
const teams = [ | |
{ | |
id: '100', | |
name: 'Team 1', | |
players: ['1', '2', '3'] | |
}, | |
{ | |
id: '200', | |
name: 'Team 2', | |
players: ['4', '5'] | |
} | |
]; | |
this.store.pushPayload('player', {players: players}); | |
this.store.pushPayload('team', {teams: teams}); | |
}, | |
model(){ | |
return null; | |
//return this.store.peekAll('team'); | |
} | |
}); |
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.11.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.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment