From 1600ab3446f533a6824512d616131c7d02a037c7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 20 Oct 2020 19:25:35 +0200 Subject: add footnote type and text plate type. keep track of footnotes when accumulating paragraphs. --- animism-align/frontend/app/constants.js | 3 +- .../frontend/app/utils/transcript.utils.js | 16 ++++++--- .../components/annotations/annotation.form.js | 11 ++++--- .../components/annotations/annotation.index.css | 7 ++++ .../annotationForms/annotationForm.text.js | 24 +++++++++++++- .../annotations/annotationForms/index.js | 2 ++ .../annotationTypes/annotationTypes.text.js | 38 ++++++++++++++++++++++ .../annotations/annotationTypes/index.js | 4 +++ .../paragraphTypes/paragraphTypes.video.js | 3 -- .../app/views/paragraph/paragraph.reducer.js | 1 + .../app/views/paragraph/transcript.actions.js | 4 +-- .../frontend/app/views/viewer/viewer.actions.js | 12 +++++-- .../frontend/app/views/viewer/viewer.reducer.js | 2 ++ 13 files changed, 108 insertions(+), 19 deletions(-) (limited to 'animism-align/frontend/app') diff --git a/animism-align/frontend/app/constants.js b/animism-align/frontend/app/constants.js index 1cf26cd..5abe350 100644 --- a/animism-align/frontend/app/constants.js +++ b/animism-align/frontend/app/constants.js @@ -46,6 +46,7 @@ export const ROMAN_NUMERALS = [ export const TEXT_ANNOTATION_TYPES = new Set([ 'section_heading', 'heading_text', 'sentence', 'paragraph_end', 'pullquote_credit', + 'footnote', 'text_plate', ]) export const MEDIA_ANNOTATION_TYPES = new Set([ @@ -68,7 +69,7 @@ export const INLINE_UTILITY_ANNOTATION_TYPES = new Set([ ]) export const FULLSCREEN_UTILITY_ANNOTATION_TYPES = new Set([ - 'curtain', + 'curtain', 'text_plate', ]) export const GALLERY_UTILITY_ANNOTATION_TYPES = new Set([ diff --git a/animism-align/frontend/app/utils/transcript.utils.js b/animism-align/frontend/app/utils/transcript.utils.js index f343d76..dc351c0 100644 --- a/animism-align/frontend/app/utils/transcript.utils.js +++ b/animism-align/frontend/app/utils/transcript.utils.js @@ -6,14 +6,16 @@ import { FULLSCREEN_UTILITY_ANNOTATION_TYPES, } from 'app/constants' -export const buildParagraphs = (annotationOrder, sectionCount) => { +export const buildParagraphs = (annotationOrder, sectionCount, footnoteCount) => { const state = store.getState() const { lookup: annotationLookup } = state.annotation.index const { lookup: paragraphLookup } = state.paragraph.index let currentParagraph = {} const paragraphs = [] + const footnotes = [] sectionCount = (sectionCount || 0) + footnoteCount = (footnoteCount || 0) // loop over the annotations in time order annotationOrder.forEach((annotation_id, i) => { @@ -85,12 +87,16 @@ export const buildParagraphs = (annotationOrder, sectionCount) => { paragraphs.push(currentParagraph) } + if (annotation.type === 'footnote') { + footnoteCount += 1 + annotation.footnote_id = footnoteCount + footnotes.push(annotation) + } + // if this annotation is a paragraph_end, set the end timestamp if (annotation.type === 'paragraph_end') { currentParagraph.end_ts = annotation.start_ts - } - - // otherwise, just append this annotation to the paragraph + } // otherwise, just append this annotation to the paragraph else { currentParagraph.annotations.push(annotation) } @@ -107,7 +113,7 @@ export const buildParagraphs = (annotationOrder, sectionCount) => { paragraphs[i].start_ts = paragraphs[i+1].start_ts - 0.01 } } - return paragraphs + return { paragraphs, footnotes } } const getParagraphType = (annotation, paragraph) => { diff --git a/animism-align/frontend/app/views/align/components/annotations/annotation.form.js b/animism-align/frontend/app/views/align/components/annotations/annotation.form.js index 8ca3c3f..92b5a5f 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotation.form.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotation.form.js @@ -14,6 +14,8 @@ import { annotationFormLookup } from './annotationForms' const ANNOTATION_TYPES = [ 'sentence', 'section_heading', 'heading_text', 'pullquote_credit', 'paragraph_end', + 'footnote', + 'text_plate', 'video', 'image', 'gallery', 'carousel', 'grid', 'vitrine', @@ -21,6 +23,10 @@ const ANNOTATION_TYPES = [ 'curtain', 'intro', 'schedule', ].map(name => ({ name, label: capitalize(name.replace('_', ' ')) })) +const annotationTextTypes = new Set([ + 'sentence', 'section_heading', 'heading_text', 'pullquote_credit', 'footnote', 'text_plate', +]) + class AnnotationForm extends Component { constructor(props){ super(props) @@ -129,10 +135,7 @@ class AnnotationForm extends Component { }} > {this.renderButtons()} - {annotation.type === 'sentence' && this.renderTextarea()} - {annotation.type === 'section_heading' && this.renderTextarea()} - {annotation.type === 'heading_text' && this.renderTextarea()} - {annotation.type === 'pullquote_credit' && this.renderTextarea()} + {annotationTextTypes.has(annotation.type) && this.renderTextarea()} {(annotation.type in annotationFormLookup) && this.renderElementForm()} ) diff --git a/animism-align/frontend/app/views/align/components/annotations/annotation.index.css b/animism-align/frontend/app/views/align/components/annotations/annotation.index.css index 7c28b43..5547408 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotation.index.css +++ b/animism-align/frontend/app/views/align/components/annotations/annotation.index.css @@ -47,6 +47,13 @@ .annotationIndex .annotation.utility { left: calc(405px + 0.5rem); } +.annotationIndex .annotation.footnote { + left: calc(405px + 0.5rem); + width: 200px; +} +.annotationIndex .annotation.text_plate { + left: calc(405px + 0.5rem); +} .annotation.curtain { background-image: linear-gradient(rgba(255,255,255,1.0), rgba(255,255,255,1.0)); width: 8rem; diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.text.js b/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.text.js index 07a79a3..aeebc55 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.text.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.text.js @@ -1,7 +1,8 @@ import React, { Component } from 'react' import { CURTAIN_COLOR_SELECT_OPTIONS, BLACK_WHITE_SELECT_OPTIONS } from 'app/constants' -import { Select, Checkbox, LabelDescription } from 'app/common' +import { Select, Checkbox, TextInput, LabelDescription } from 'app/common' +import { AnnotationFormFullscreen } from './annotationForm.utility' export const AnnotationFormSectionHeading = ({ annotation, handleSettingsSelect, handleSettingsChange }) => { return ( @@ -61,3 +62,24 @@ export const AnnotationFormSectionHeading = ({ annotation, handleSettingsSelect, ) } + +export const AnnotationFormTextPlate = ({ annotation, handleSettingsSelect, handleSettingsChange }) => { + return ( +
+