decide.nolog.cz/app/serializers/poll.js

28 lines
664 B
JavaScript
Raw Normal View History

2018-12-29 01:27:37 +01:00
import { isEmpty } from '@ember/utils';
2016-01-28 23:48:14 +01:00
import DS from 'ember-data';
import ApplicationAdapter from './application';
2014-10-30 21:44:22 +01:00
export default ApplicationAdapter.extend(DS.EmbeddedRecordsMixin, {
attrs: {
users: {
deserialize: 'records'
}
2015-10-25 16:46:11 +01:00
},
legacySupport(resourceHash) {
// croodle <= 0.3.0
2016-01-28 23:48:14 +01:00
// property 'type' of answers was named 'id'
2015-10-25 16:46:11 +01:00
if (
resourceHash.answers.length > 0 &&
2018-12-29 01:27:37 +01:00
!isEmpty(resourceHash.answers[0].id)
2015-10-25 16:46:11 +01:00
) {
resourceHash.answers.forEach((answer, index) => {
resourceHash.answers[index].type = answer.id;
delete resourceHash.answers[index].id;
});
}
return resourceHash;
}
});