2017-05-29 21:50:03 +03:00
|
|
|
import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support';
|
|
|
|
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
|
2020-01-16 20:01:12 +03:00
|
|
|
import RESTAdapter from '@ember-data/adapter/rest';
|
2016-05-24 15:06:59 +03:00
|
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2015-11-04 18:20:11 +03:00
|
|
|
|
2016-09-26 19:59:04 +03:00
|
|
|
export default RESTAdapter.extend(DataAdapterMixin, AjaxServiceSupport, {
|
2014-12-26 03:01:02 +03:00
|
|
|
host: window.location.origin,
|
|
|
|
namespace: ghostPaths().apiRoot.slice(1),
|
|
|
|
|
2017-10-30 12:38:01 +03:00
|
|
|
session: service(),
|
2015-11-04 18:20:11 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
shouldBackgroundReloadRecord() {
|
2015-10-19 18:35:17 +03:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
query(store, type, query) {
|
|
|
|
let id;
|
2014-12-26 03:01:02 +03:00
|
|
|
|
|
|
|
if (query.id) {
|
|
|
|
id = query.id;
|
|
|
|
delete query.id;
|
|
|
|
}
|
|
|
|
|
2015-06-03 05:56:42 +03:00
|
|
|
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
|
2014-12-26 03:01:02 +03:00
|
|
|
},
|
|
|
|
|
2016-01-13 17:47:10 +03:00
|
|
|
buildURL() {
|
2014-12-26 03:01:02 +03:00
|
|
|
// Ensure trailing slashes
|
2016-01-13 17:47:10 +03:00
|
|
|
let url = this._super(...arguments);
|
2014-12-26 03:01:02 +03:00
|
|
|
|
|
|
|
if (url.slice(-1) !== '/') {
|
|
|
|
url += '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
});
|