cms/app-client/app/serializers/transcript.js
author Chloe Laisne <chloe.laisne@gmail.com>
Fri, 05 Aug 2016 18:51:59 +0200
changeset 253 0be9770b09b4
parent 245 c9dd78a43b07
child 255 ed05b89e3299
permissions -rw-r--r--
Hide/show transcript button in the player - Do not request transscript when property is null in the document request

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

});