cms/app-client/app/serializers/transcript.js
changeset 255 ed05b89e3299
parent 245 c9dd78a43b07
child 256 18f0c3ee9aa5
--- a/cms/app-client/app/serializers/transcript.js	Tue Aug 16 00:16:08 2016 +0200
+++ b/cms/app-client/app/serializers/transcript.js	Wed Aug 17 15:30:19 2016 +0200
@@ -5,12 +5,27 @@
 	normalizeResponse: function(store, primaryModelClass, payload, id, requestType) {
 		var annotations = [];
 		payload.annotations.forEach(function(annotation) {
-			annotations.push({
+			console.log('ANNOT', annotation.content.data.words);
+			var annotationObject = {
 				'content': annotation.content.data.content,
-				'translation': annotation.content.data.transl['@value'],
 				'start': annotation.begin,
 				'end': annotation.end
-			});
+			};
+			if(annotation.content.data.transl) {
+				annotationObject.translation = annotation.content.data.transl['@value'];
+			}
+			if(annotation.content.data.words) {
+				var words = [];
+				annotation.content.data.words.forEach(function(word) {
+					var wordObject = {
+						'content': word.content,
+						'translation': word.transl['@value']
+					};
+					words.push(wordObject);
+				})
+				annotationObject.words = words;
+			}
+			annotations.push(annotationObject);
 		});
         return {
             'data': {