From 4bb72b9f6d2a56fc6bd67f4248fcabfcc8166493 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 17 Jul 2020 18:52:24 +0200 Subject: refactor annotation and paragraph types --- .../components/annotations/annotation.form.js | 43 +++----- .../components/annotations/annotation.index.js | 2 +- .../components/annotations/annotation.types.js | 108 --------------------- .../annotationForms/annotationForm.image.js | 27 ++++++ .../annotationForms/annotationForm.video.js | 27 ++++++ .../annotations/annotationForms/index.js | 12 +++ .../annotationTypes/annotationTypes.image.js | 33 +++++++ .../annotationTypes/annotationTypes.text.js | 49 ++++++++++ .../annotationTypes/annotationTypes.util.js | 28 ++++++ .../annotationTypes/annotationTypes.video.js | 34 +++++++ .../annotations/annotationTypes/index.js | 22 +++++ .../views/paragraph/components/paragraph.types.js | 62 ------------ .../paragraph/components/paragraphTypes/index.js | 16 +++ .../paragraphTypes/paragraphTypes.text.js | 36 +++++++ .../paragraphTypes/paragraphTypes.video.js | 19 ++++ .../containers/paragraphList.container.js | 2 +- 16 files changed, 321 insertions(+), 199 deletions(-) delete mode 100644 animism-align/frontend/views/align/components/annotations/annotation.types.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.image.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.video.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationForms/index.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.image.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.text.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.util.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.video.js create mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/index.js delete mode 100644 animism-align/frontend/views/paragraph/components/paragraph.types.js create mode 100644 animism-align/frontend/views/paragraph/components/paragraphTypes/index.js create mode 100644 animism-align/frontend/views/paragraph/components/paragraphTypes/paragraphTypes.text.js create mode 100644 animism-align/frontend/views/paragraph/components/paragraphTypes/paragraphTypes.video.js (limited to 'animism-align/frontend/views') 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 53f640f..01b1663 100644 --- a/animism-align/frontend/views/align/components/annotations/annotation.form.js +++ b/animism-align/frontend/views/align/components/annotations/annotation.form.js @@ -11,8 +11,13 @@ import { clamp, timestamp, capitalize } from '../../../../util' import { timeToPosition } from '../../align.util' import { Select } from '../../../../common' +import { + AnnotationFormVideo, + AnnotationFormImage, +} from './annotationForms' + const ANNOTATION_TYPES = [ - 'sentence', 'header', 'paragraph_end', 'video', + 'sentence', 'header', 'paragraph_end', 'video', 'image', 'image_carousel', ].map(name => ({ name, label: capitalize(name.replace('_', ' ')) })) class AnnotationForm extends Component { @@ -105,7 +110,7 @@ class AnnotationForm extends Component { } } render() { - const { timeline, annotation } = this.props + const { timeline, annotation, media } = this.props if (!annotation.start_ts) return
return (
+ } + {annotation.type === 'image' && + + } + {annotation.type === 'image_carousel' && + + }
) } @@ -156,30 +169,6 @@ 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 ( -
- +
+ ) +} diff --git a/animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.video.js b/animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.video.js new file mode 100644 index 0000000..9302ba4 --- /dev/null +++ b/animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.video.js @@ -0,0 +1,27 @@ +import React, { Component } from 'react' + +import { Select } from '../../../../../common' + +export const AnnotationFormVideo = ({ annotation, media, handleSettingsSelect }) => { + 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 ( +
+