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';
|
2015-08-19 22:00:01 +02:00
|
|
|
import ApplicationAdapter from './application';
|
2014-10-30 21:44:22 +01:00
|
|
|
|
2015-08-19 22:00:01 +02:00
|
|
|
export default ApplicationAdapter.extend(DS.EmbeddedRecordsMixin, {
|
2014-09-28 14:55:40 +02:00
|
|
|
attrs: {
|
2015-01-20 22:47:04 +01:00
|
|
|
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;
|
2014-09-28 14:55:40 +02:00
|
|
|
}
|
2015-08-19 22:00:01 +02:00
|
|
|
});
|