mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
ba4c53134f
no issue - update imports for `@ember-data` package (https://github.com/emberjs/rfcs/blob/master/text/0395-ember-data-packages.md) - use `computed.reads` where applicable (https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/require-computed-macros.md) - fix usage of `scheduleOnce` so that functions are only scheduled once (https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-incorrect-calls-with-inline-anonymous-functions.md)
39 lines
978 B
JavaScript
39 lines
978 B
JavaScript
import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support';
|
|
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
|
|
import RESTAdapter from '@ember-data/adapter/rest';
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default RESTAdapter.extend(DataAdapterMixin, AjaxServiceSupport, {
|
|
host: window.location.origin,
|
|
namespace: ghostPaths().apiRoot.slice(1),
|
|
|
|
session: service(),
|
|
|
|
shouldBackgroundReloadRecord() {
|
|
return false;
|
|
},
|
|
|
|
query(store, type, query) {
|
|
let id;
|
|
|
|
if (query.id) {
|
|
id = query.id;
|
|
delete query.id;
|
|
}
|
|
|
|
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
|
|
},
|
|
|
|
buildURL() {
|
|
// Ensure trailing slashes
|
|
let url = this._super(...arguments);
|
|
|
|
if (url.slice(-1) !== '/') {
|
|
url += '/';
|
|
}
|
|
|
|
return url;
|
|
}
|
|
});
|