cms/app-client/app/serializers/transcript.js
author Chloe Laisne <chloe.laisne@gmail.com>
Wed, 20 Jul 2016 21:08:31 +0200
changeset 245 c9dd78a43b07
child 255 ed05b89e3299
permissions -rw-r--r--
Transcript model and erializer Transcript component Update Ember-cli to 2.6.3

import JSONAPISerializer from 'ember-data/serializers/json-api';

export default JSONAPISerializer.extend({

	normalizeResponse: function(store, primaryModelClass, payload, id, requestType) {
		var annotations = [];
		payload.annotations.forEach(function(annotation) {
			annotations.push({
				'content': annotation.content.data.content,
				'translation': annotation.content.data.transl['@value'],
				'start': annotation.begin,
				'end': annotation.end
			});
		});
        return {
            'data': {
	            'id': id,
	            'type': 'transcript',
	            'attributes': {
	                'title': payload.meta['dc:title']['@value'],
	                'annotations': annotations
	            }
	        }
        };
	}

});