Last active
June 20, 2016 08:38
-
-
Save Sinled/ab180cffeddeda454721f8a7d489ed96 to your computer and use it in GitHub Desktop.
test-delete-poly-record-with-relations
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({ | |
actions: { | |
deleteRecord(item) { | |
item.deleteRecord(); | |
alert('delete'); | |
}, | |
unloadRecord(item) { | |
item.unloadRecord(); | |
alert('unload'); | |
}, | |
} | |
}); |
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"; | |
import MyModel from './my-model'; | |
export default MyModel.extend({ | |
somePolyField: attr('string', { defaultValue: 'hello from poly' }), | |
}); |
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({ | |
someField: attr('number', { defaultValue: 1 }), | |
parent: belongsTo('parent-model'), | |
}); |
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({ | |
someNormalField: attr('string', { defaultValue: 'hello from normal' }), | |
parent: belongsTo('parent-model'), | |
}); |
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"; | |
import Ember from 'ember'; | |
export default Model.extend({ | |
myPolymorphicModels: hasMany('my-model', { async: false }), | |
myNormalModels: hasMany('normal-model', { async: false }), | |
myPolymotphicRecord: Ember.computed('myPolymorphicModels.[]', function() { | |
return this.get('myPolymorphicModels.firstObject'); | |
}), | |
myNormalRecord: Ember.computed('myNormalModels.[]', function() { | |
return this.get('myNormalModels.firstObject'); | |
}), | |
}); |
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() { | |
const parent = this.store.createRecord('parent-model'); | |
const polymorhicRecord = this.store.createRecord('my-model-poly', { parent }); | |
const normalRecord = this.store.createRecord('normal-model', { parent }); | |
parent.get('myNormalModels').addObject(normalRecord); | |
parent.get('myPolymorphicModels').addObject(polymorhicRecord); | |
return { | |
parent, | |
}; | |
}, | |
}); |
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.9.2", | |
"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.6.0", | |
"ember-data": "2.6.0", | |
"ember-template-compiler": "2.6.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment