mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
8cbc6dc3b7
closes #2998 - update PostSerializer to use DS.EmbeddedRecordsMixin - create PostAdapter to include include=tags in query params for POST and PUT - set include=tags for various GET post requests - change PostModel to have { embedded: always } instead of { async: true } - update Ember-Data to beta8 from beta7 - make call to get tags from model in editor.edit route synchronous since the tags now exist in the store - change casper test to wait for call to posts api with `?include=tags`
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import ApplicationAdapter from 'ghost/adapters/application';
|
|
|
|
var PostAdapter = ApplicationAdapter.extend({
|
|
createRecord: function (store, type, record) {
|
|
var data = {},
|
|
serializer = store.serializerFor(type.typeKey),
|
|
url = this.buildURL(type.typeKey);
|
|
|
|
// make the server return with the tags embedded
|
|
url = url + '?include=tags';
|
|
|
|
// use the PostSerializer to transform the model back into
|
|
// an array with a post object like the API expects
|
|
serializer.serializeIntoHash(data, type, record);
|
|
|
|
return this.ajax(url, 'POST', { data: data });
|
|
},
|
|
|
|
updateRecord: function (store, type, record) {
|
|
var data = {},
|
|
serializer = store.serializerFor(type.typeKey),
|
|
id = Ember.get(record, 'id'),
|
|
url = this.buildURL(type.typeKey, id);
|
|
|
|
// make the server return with the tags embedded
|
|
url = url + '?include=tags';
|
|
|
|
// use the PostSerializer to transform the model back into
|
|
// an array of posts objects like the API expects
|
|
serializer.serializeIntoHash(data, type, record);
|
|
|
|
// use the ApplicationAdapter's buildURL method
|
|
return this.ajax(url, 'PUT', { data: data });
|
|
}
|
|
});
|
|
|
|
export default PostAdapter;
|