2018-09-25 16:28:26 +00:00
|
|
|
import { set } from '@ember/object';
|
2018-04-03 14:16:57 +00:00
|
|
|
import ApplicationAdapter from './application';
|
|
|
|
import DS from 'ember-data';
|
|
|
|
|
|
|
|
export default ApplicationAdapter.extend({
|
|
|
|
pathForType() {
|
|
|
|
return 'capabilities-self';
|
|
|
|
},
|
|
|
|
|
|
|
|
findRecord(store, type, id) {
|
2018-04-20 01:51:41 +00:00
|
|
|
return this.ajax(this.buildURL(type), 'POST', { data: { paths: [id] } }).catch(e => {
|
2018-04-03 14:16:57 +00:00
|
|
|
if (e instanceof DS.AdapterError) {
|
2018-09-25 16:28:26 +00:00
|
|
|
set(e, 'policyPath', 'sys/capabilities-self');
|
2018-04-03 14:16:57 +00:00
|
|
|
}
|
|
|
|
throw e;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
queryRecord(store, type, query) {
|
|
|
|
const { id } = query;
|
2018-10-09 04:21:02 +00:00
|
|
|
if (!id) {
|
|
|
|
return;
|
|
|
|
}
|
2018-04-03 14:16:57 +00:00
|
|
|
return this.findRecord(store, type, id).then(resp => {
|
|
|
|
resp.path = id;
|
|
|
|
return resp;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|