2018-04-03 14:16:57 +00:00
|
|
|
import ApplicationSerializer from './application';
|
|
|
|
|
|
|
|
export default ApplicationSerializer.extend({
|
|
|
|
normalizeBackend(path, backend) {
|
2018-07-05 18:28:12 +00:00
|
|
|
let struct = { ...backend };
|
2018-04-03 14:16:57 +00:00
|
|
|
// strip the trailing slash off of the path so we
|
|
|
|
// can navigate to it without getting `//` in the url
|
|
|
|
struct.id = path.slice(0, -1);
|
|
|
|
struct.path = path;
|
|
|
|
return struct;
|
|
|
|
},
|
|
|
|
|
|
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
|
|
const isCreate = requestType === 'createRecord';
|
|
|
|
const backends = isCreate
|
|
|
|
? payload.data
|
2018-07-05 18:28:12 +00:00
|
|
|
: Object.keys(payload.data).map(path => this.normalizeBackend(path, payload.data[path]));
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
return this._super(store, primaryModelClass, backends, id, requestType);
|
|
|
|
},
|
|
|
|
});
|