Allow child adapters specify special xhr keys
This is necessary for the namespace query param
This commit is contained in:
parent
d85673d7c6
commit
ca98d6b0c8
|
@ -46,6 +46,18 @@ export default Watchable.extend({
|
|||
return url;
|
||||
},
|
||||
|
||||
xhrKey(url, method, options = {}) {
|
||||
const namespace = options.data && options.data.namespace;
|
||||
if (namespace) {
|
||||
return `${url}?namespace=${namespace}`;
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
relationshipFallbackLinks: {
|
||||
summary: '/summary',
|
||||
},
|
||||
|
||||
findAllocations(job) {
|
||||
const url = `${this.buildURL('job', job.get('id'), job, 'findRecord')}/allocations`;
|
||||
return this.ajax(url, 'GET', { data: this.buildQuery() }).then(allocs => {
|
||||
|
|
|
@ -13,30 +13,34 @@ export default ApplicationAdapter.extend({
|
|||
return {};
|
||||
}),
|
||||
|
||||
ajaxOptions(url) {
|
||||
ajaxOptions() {
|
||||
const ajaxOptions = this._super(...arguments);
|
||||
const key = this.xhrKey(...arguments);
|
||||
|
||||
const previousBeforeSend = ajaxOptions.beforeSend;
|
||||
ajaxOptions.beforeSend = function(jqXHR) {
|
||||
if (previousBeforeSend) {
|
||||
previousBeforeSend(...arguments);
|
||||
}
|
||||
this.get('xhrs')[url] = jqXHR;
|
||||
this.get('xhrs')[key] = jqXHR;
|
||||
jqXHR.always(() => {
|
||||
delete this.get('xhrs')[url];
|
||||
delete this.get('xhrs')[key];
|
||||
});
|
||||
};
|
||||
|
||||
return ajaxOptions;
|
||||
},
|
||||
|
||||
xhrKey(url /* method, options */) {
|
||||
return url;
|
||||
},
|
||||
|
||||
findAll(store, type, sinceToken, snapshotRecordArray, additionalParams = {}) {
|
||||
const params = assign(this.buildQuery(), additionalParams);
|
||||
const url = this.urlForFindAll(type.modelName);
|
||||
|
||||
if (get(snapshotRecordArray || {}, 'adapterOptions.watch')) {
|
||||
params.index = this.get('watchList').getIndexFor(url);
|
||||
this.cancelFindAll(type.modelName);
|
||||
}
|
||||
|
||||
return this.ajax(url, 'GET', {
|
||||
|
|
Loading…
Reference in a new issue