2018-09-25 16:28:26 +00:00
|
|
|
import { assign } from '@ember/polyfills';
|
2018-05-30 02:56:15 +00:00
|
|
|
import ApplicationSerializer from '../application';
|
|
|
|
|
|
|
|
export default ApplicationSerializer.extend({
|
|
|
|
normalizeItems(payload) {
|
|
|
|
if (payload.data.keys && Array.isArray(payload.data.keys)) {
|
|
|
|
return payload.data.keys;
|
|
|
|
}
|
2018-09-25 16:28:26 +00:00
|
|
|
assign(payload, payload.data);
|
2018-05-30 02:56:15 +00:00
|
|
|
delete payload.data;
|
|
|
|
return payload;
|
|
|
|
},
|
|
|
|
|
|
|
|
extractLazyPaginatedData(payload) {
|
|
|
|
let list;
|
|
|
|
list = payload.data.keys.map(key => {
|
|
|
|
let model = payload.data.key_info[key];
|
|
|
|
model.id = key;
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
delete payload.data.key_info;
|
2018-06-01 22:18:31 +00:00
|
|
|
return list.sort((a, b) => {
|
2018-05-30 02:56:15 +00:00
|
|
|
return a.name.localeCompare(b.name);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|