Created
August 30, 2016 18:24
-
-
Save jking6884/ed1f34a801c017c578ae88fab8879cc5 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 Ember from 'ember'; | |
/** | |
* use to support non restful actions on your api | |
* | |
* see more: | |
* http://articles.jeffjewiss.com/non-restful-actions-mixin-for-ember-data-model/ | |
* | |
*/ | |
export default Ember.Mixin.create({ | |
nonRestRouteAction: function (action, method, data, modelName) { | |
const adapter = this.store.adapterFor(modelName); | |
return adapter.ajax(action, method, {data: data}); | |
} | |
}); |
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
// ask for additional data to be sideloaded | |
model: function (params) { | |
var queryString = // code omitted here | |
return Ember.RSVP.hash({ | |
model: this.nonRestRouteAction(getAppUrl(ENV, queryString), 'GET', {}, 'eligible-billable').then((result) => { | |
return this.store.pushPayload('eligible-billable', result); | |
}), | |
matterTypes: this.store.query('matter-type', {active: 1}) | |
}); | |
}, | |
setupController: function (controller, resolved) { | |
// resolved.matterTypes is set, but resolved.model is undefined | |
}, |
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 {ActiveModelSerializer} from 'active-model-adapter'; | |
export default ActiveModelSerializer.extend({ | |
normalize: function (typeClass, hash, prop) { | |
return this._super(typeClass, hash, prop); | |
}, | |
//http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_upgrade-guide | |
isNewSerializerAPI: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment