Last active
September 26, 2019 05:27
-
-
Save lsg-braymon/c0363fcbee3d705ddf24df9263b2f531 to your computer and use it in GitHub Desktop.
Unload record error
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' | |
}); |
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({ | |
mainGroup: Ember.computed('model', function() { | |
return this.model.filter(function(group){ | |
return group.group === null; | |
}); | |
}), | |
actions: { | |
onCreateGroup: function(item) { | |
const newGroup = this.store.createRecord('group'); | |
newGroup.setProperties({ | |
name: 'New Group', | |
group: item.group | |
}); | |
item.set('group', newGroup); | |
}, | |
onUnloadItem: function(item) { | |
item.unloadRecord(); | |
} | |
} | |
}); |
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
export default function() { | |
this.get('/groups', function(){ | |
return { | |
data: [ | |
{ | |
id: '1', | |
type: 'groups', | |
attributes: { | |
name: 'Main Group' | |
}, | |
relationships: { | |
items: { | |
data: [ | |
{ type: 'items', id: 'item-1' }, | |
{ type: 'items', id: 'item-2' }, | |
{ type: 'items', id: 'item-3' }, | |
] | |
} | |
} | |
} | |
], | |
included: [ | |
{ | |
id: 'item-1', | |
type: 'items', | |
attributes: { name: 'Item 1' } | |
}, | |
{ | |
id: 'item-2', | |
type: 'items', | |
attributes: { name: 'Item 2' } | |
}, | |
{ | |
id: 'item-3', | |
type: 'items', | |
attributes: { name: 'Item 3' } | |
} | |
] | |
} | |
}) | |
}; |
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 { JSONAPISerializer } from 'ember-cli-mirage'; | |
export default JSONAPISerializer; |
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'), | |
group: belongsTo('group', { async: false, inverse: 'groups' }), | |
items: hasMany('item', { async: false }), | |
groups: hasMany('group', { async: false, inverse: 'group' }) | |
}); |
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'), | |
group: belongsTo('group', { async: false }) | |
}); |
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() { | |
return this.store.findAll('group'); | |
} | |
}); |
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.15.1", | |
"ENV": { | |
"ember-cli-mirage": { | |
"enabled": true | |
} | |
}, | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-cli-mirage": "0.4.14" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment