cms/app-client/app/serializers/transcript.js
author Chloe Laisne <chloe.laisne@gmail.com>
Fri, 05 Aug 2016 14:55:45 +0200
changeset 251 ac320de33ec7
parent 245 c9dd78a43b07
child 255 ed05b89e3299
permissions -rw-r--r--
Add transcript button to player-component

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
	            }
	        }
        };
	}

});