Ghost/ghost/admin/app/adapters/base.js
Kevin Ansfield 0cd88bce7d Keep old shouldBackgroundReloadRecord behaviour ready for 2.0 upgrade
no issue
- adds `shouldBackgroundReloadRecord` override so that we keep the current behaviour (never background reload unless instigated manually) when we upgrade to Ember Data 2.0 which will always background-reload by default
2015-10-23 18:18:58 +01:00

48 lines
1.3 KiB
JavaScript

import DS from 'ember-data';
import ghostPaths from 'ghost/utils/ghost-paths';
export default DS.RESTAdapter.extend({
host: window.location.origin,
namespace: ghostPaths().apiRoot.slice(1),
shouldBackgroundReloadRecord: function () {
return false;
},
query: function (store, type, query) {
var id;
if (query.id) {
id = query.id;
delete query.id;
}
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
},
buildURL: function (type, id) {
// Ensure trailing slashes
var url = this._super(type, id);
if (url.slice(-1) !== '/') {
url += '/';
}
return url;
},
// Override deleteRecord to disregard the response body on 2xx responses.
// This is currently needed because the API is returning status 200 along
// with the JSON object for the deleted entity and Ember expects an empty
// response body for successful DELETEs.
// Non-2xx (failure) responses will still work correctly as Ember will turn
// them into rejected promises.
deleteRecord: function () {
var response = this._super.apply(this, arguments);
return response.then(function () {
return null;
});
}
});