From 18472645a7879baf00332a7ee5be8c4338bb8d21 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 8 Jul 2020 23:37:40 +0200 Subject: adding annotations of type video --- .../components/annotations/annotation.form.js | 63 +++++++++++++++++----- 1 file changed, 50 insertions(+), 13 deletions(-) (limited to 'animism-align/frontend/views/align/components/annotations/annotation.form.js') diff --git a/animism-align/frontend/views/align/components/annotations/annotation.form.js b/animism-align/frontend/views/align/components/annotations/annotation.form.js index 226bb45..0a71233 100644 --- a/animism-align/frontend/views/align/components/annotations/annotation.form.js +++ b/animism-align/frontend/views/align/components/annotations/annotation.form.js @@ -12,7 +12,7 @@ import { timeToPosition } from '../../align.util' import { Select } from '../../../../common' const ANNOTATION_TYPES = [ - 'sentence', 'header', 'paragraph_end' + 'sentence', 'header', 'paragraph_end', 'video', ].map(name => ({ name, label: name })) class AnnotationForm extends Component { @@ -20,6 +20,7 @@ class AnnotationForm extends Component { super(props) this.handleChange = this.handleChange.bind(this) this.handleSelect = this.handleSelect.bind(this) + this.handleSettingsSelect = this.handleSettingsSelect.bind(this) this.handleKeyDown = this.handleKeyDown.bind(this) this.handleSubmit = this.handleSubmit.bind(this) this.textareaRef = React.createRef() @@ -66,6 +67,10 @@ class AnnotationForm extends Component { handleSelect(name, value) { actions.align.updateAnnotationForm(name, value) } + handleSettingsSelect(name, value) { + if (name.indexOf('_id') !== -1) value = parseInt(value) || 0 + actions.align.updateAnnotationSettings(name, value) + } handleSubmit() { const { annotation } = this.props if (annotation.type === 'paragraph_end') { @@ -96,21 +101,28 @@ class AnnotationForm extends Component { top: timeToPosition(annotation.start_ts, timeline), }} > + {this.renderButtons()} {annotation.type === 'sentence' && this.renderTextarea()} {annotation.type === 'header' && this.renderTextarea()} -
-
- +
{timestamp(annotation.start_ts, 1, true)}
+
) } @@ -128,11 +140,36 @@ class AnnotationForm extends Component { ) } + renderVideo() { + const { annotation, media } = this.props + if (!media.lookup) return
+ const { lookup, order } = media + const video_list_items = order.filter(id => lookup[id].type === 'video').map(id => { + const video = lookup[id] + return { + name: video.id, + label: video.author + ' - ' + video.title + } + }) + return ( +
+