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

34 lines
1 KiB
JavaScript
Raw Normal View History

2015-10-25 16:46:11 +01:00
import ApplicationAdapter from './application';
import Ember from 'ember';
export default ApplicationAdapter.extend({
2016-01-31 14:32:32 +01:00
legacySupport(resourceHash) {
2015-10-25 16:46:11 +01:00
/*
* Croodle <= 0.3.0:
* * for answer type "freetext":
* selections where a string containing label
* * all other answer types ("YesNo", "YesNoMaybe"):
* selections where stored as child object of "value" property
* and selection property "type" where named "id"
*/
if (!Ember.isEmpty(resourceHash.selections[0].value)) {
resourceHash.selections.forEach(function(selection, index) {
if (typeof selection.value === 'string') {
resourceHash.selections[index] = {
label: selection.value
};
} else {
resourceHash.selections[index] = {
icon: selection.value.icon,
label: selection.value.label,
labelTranslation: selection.value.labelTranslation,
type: selection.value.id
};
}
});
}
2016-01-31 14:32:32 +01:00
2015-10-25 16:46:11 +01:00
return resourceHash;
}
});