# HG changeset patch # User Chloe Laisne # Date 1471532522 -7200 # Node ID 18f0c3ee9aa50cc8383b8bd67633c86ff3cc46a6 # Parent ed05b89e3299217321a843ee345ead364e48b1e2 Add title translation to transcript diff -r ed05b89e3299 -r 18f0c3ee9aa5 cms/app-client/app/serializers/transcript.js --- a/cms/app-client/app/serializers/transcript.js Wed Aug 17 15:30:19 2016 +0200 +++ b/cms/app-client/app/serializers/transcript.js Thu Aug 18 17:02:02 2016 +0200 @@ -2,41 +2,62 @@ export default JSONAPISerializer.extend({ - normalizeResponse: function(store, primaryModelClass, payload, id, requestType) { - var annotations = []; - payload.annotations.forEach(function(annotation) { - console.log('ANNOT', annotation.content.data.words); - var annotationObject = { - 'content': annotation.content.data.content, - '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 { + normalizeResponse: function(store, primaryModelClass, payload, id, requestType) { + var lang = false; + + var annotations = []; + payload.annotations.forEach(function(annotation) { + var annotationObject = { + 'content': annotation.content.data.content, + 'start': annotation.begin, + 'end': annotation.end + }; + if(annotation.content.data.transl) { + annotationObject.translation = annotation.content.data.transl['@value']; + if (!lang) { + lang = annotation.content.data.transl['@language']; + } + } + 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); + }); + + var response = { 'data': { - 'id': id, - 'type': 'transcript', - 'attributes': { - 'title': payload.meta['dc:title']['@value'], - 'annotations': annotations - } - } + 'id': id, + 'type': 'transcript', + 'attributes': { + 'title': {}, + 'annotations': annotations + } + } }; - } + + if(Array.isArray(payload.meta['dc:title'])) { + var original = payload.meta['dc:title'].find(function(title) { return title['@language'] !== lang; }); + var translation = payload.meta['dc:title'].find(function(title) { return title['@language'] === lang; }); + if(original) { + response.data.attributes.title.original = original['@value']; + } + if(translation) { + response.data.attributes.title.translation = translation['@value']; + } + } else { + response.data.attributes.title.original = payload.meta['dc:title']['@value']; + } + + + return response; + } }); diff -r ed05b89e3299 -r 18f0c3ee9aa5 cms/app-client/app/styles/components/transcript-component.scss --- a/cms/app-client/app/styles/components/transcript-component.scss Wed Aug 17 15:30:19 2016 +0200 +++ b/cms/app-client/app/styles/components/transcript-component.scss Thu Aug 18 17:02:02 2016 +0200 @@ -14,9 +14,15 @@ z-index: 1; width: inherit; background: linear-gradient($light-blue, $light-blue 50%, transparent); - padding-bottom: 54px; + padding-top: 12px; + padding-bottom: 66px; line-height: 30px; - margin: 12px auto; + margin: 0px!important; +} + +.transcript-component h2 span{ + display: block; + color: $medium-grey; } body.videoscreen .transcript-component h2 { diff -r ed05b89e3299 -r 18f0c3ee9aa5 cms/app-client/app/templates/components/transcript-component.hbs --- a/cms/app-client/app/templates/components/transcript-component.hbs Wed Aug 17 15:30:19 2016 +0200 +++ b/cms/app-client/app/templates/components/transcript-component.hbs Thu Aug 18 17:02:02 2016 +0200 @@ -1,4 +1,9 @@ -

{{player.transcript.title}}

+

+ {{player.transcript.title.original}} +{{#if player.transcript.title.translation}} + {{player.transcript.title.translation}} +{{/if}} +

    {{#each player.transcript.annotations as |annotation|}} {{log 'each-annotation'}}