From af17cb4e5de2d236305c208de9c4bc16efdc04b8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 9 Sep 2020 18:55:59 +0200 Subject: keep track of carousel advance instructions --- .../components/annotations/annotation.form.js | 1 + .../components/annotations/annotation.index.js | 2 +- .../annotationForms/annotationForm.gallery.js | 79 +++++++++++++++++++++- .../annotations/annotationForms/index.js | 3 + .../annotationTypes/annotationTypes.gallery.js | 25 +++++++ .../annotationTypes/annotationTypes.utility.js | 2 +- .../annotations/annotationTypes/index.js | 3 + 7 files changed, 111 insertions(+), 4 deletions(-) (limited to 'animism-align/frontend/app/views/align/components/annotations') 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 f20e70a..985e592 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 @@ -17,6 +17,7 @@ const ANNOTATION_TYPES = [ 'video', 'image', 'gallery', 'carousel', 'grid', 'vitrine', + 'gallery_advance', 'curtain', 'intro', 'schedule', ].map(name => ({ name, label: capitalize(name.replace('_', ' ')) })) diff --git a/animism-align/frontend/app/views/align/components/annotations/annotation.index.js b/animism-align/frontend/app/views/align/components/annotations/annotation.index.js index 0f9ee30..44b27d7 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotation.index.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotation.index.js @@ -38,7 +38,7 @@ class AnnotationIndex extends PureComponent { const items = order.filter(id => { const { start_ts: ts } = lookup[id] return (timeMin < ts && ts < timeMax) - }).map(id => lookup[id]).reverse() + }).map(id => lookup[id]) this.setState({ items }) } handleClick(e, annotation) { diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.gallery.js b/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.gallery.js index 5fb8958..c43d8d5 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.gallery.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.gallery.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import { CURTAIN_COLOR_SELECT_OPTIONS } from 'app/constants' -import { TextInput, Select, Checkbox } from 'app/common' +import { TextInput, Select, Checkbox, LabelDescription } from 'app/common' import { AnnotationFormFullscreen } from './annotationForm.utility' export const AnnotationFormGallery = ({ annotation, media, handleSettingsSelect, handleSettingsChange }) => { @@ -21,7 +21,7 @@ export const AnnotationFormGallery = ({ annotation, media, handleSettingsSelect, className="media_id" selected={annotation.settings.media_id} options={image_list_items} - defaultOption='Choose an image' + defaultOption='Choose a gallery' onChange={handleSettingsSelect} /> @@ -74,3 +74,78 @@ export const AnnotationFormGallery = ({ annotation, media, handleSettingsSelect, ) } + +export const AnnotationFormGalleryAdvance = ({ annotation, media, handleSettingsSelect, handleSettingsChange }) => { + if (!media.lookup) return
+ const { lookup, order } = media + const image_list_items = order.filter(id => lookup[id].type === 'gallery').map(id => { + const image = lookup[id] + return { + name: image.id, + label: image.author + ' - ' + image.title + } + }) + let item, gallery_items, frame_id, thumbnail + if (annotation.settings.media_id && lookup[annotation.settings.media_id]) { + item = lookup[annotation.settings.media_id] + gallery_items = item.settings.image_order.map((id, index) => { + const caption = item.settings.caption_lookup && item.settings.caption_lookup[id] + console.log(caption) + return { + name: index, + label: (index + 1) + ") " + (caption ? (caption.title || "") : "") + } + }) + if (annotation.settings.frame_index) { + frame_id = item.settings.image_order[annotation.settings.frame_index] + thumbnail = item.settings.thumbnail_lookup[frame_id] + } + } + return ( +
+ + )} + + {thumbnail && ( + + )} + + + + + + +
+ ) +} diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationForms/index.js b/animism-align/frontend/app/views/align/components/annotations/annotationForms/index.js index a4ad015..5cbe773 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationForms/index.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationForms/index.js @@ -12,6 +12,7 @@ import { import { AnnotationFormGallery, + AnnotationFormGalleryAdvance, } from './annotationForm.gallery' import { @@ -30,6 +31,8 @@ export const annotationFormLookup = { grid: AnnotationFormGallery, vitrine: AnnotationFormGallery, + gallery_advance: AnnotationFormGalleryAdvance, + intro: AnnotationFormIntro, curtain: AnnotationFormCurtain, } diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.gallery.js b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.gallery.js index e25f78e..61d24e3 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.gallery.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.gallery.js @@ -48,3 +48,28 @@ export const AnnotationGallery = ({ y, annotation, media, timeline, selected, on ) } + +export const AnnotationGalleryAdvance = ({ y, annotation, media, timeline, selected, onClick, onDoubleClick }) => { + const className = selected ? 'annotation media gallery_advance selected' : 'annotation media gallery_advance' + const style = { + top: y, + } + let index = parseInt(annotation.settings.frame_index) + 1 + if (annotation.settings.half_frame) { + index += 0.5 + } + return ( +
onClick(e, annotation)} + onDoubleClick={e => onDoubleClick(e, annotation)} + > +
+
+ Advance gallery to frame {index} +
+
+
+ ) +} diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.utility.js b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.utility.js index 55257ef..07c986c 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.utility.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.utility.js @@ -83,7 +83,7 @@ export const checkAnnotationMediaNotReady = (annotation, media) => { return (!media) || (!(annotation.settings.media_id in media)) } -export const AnnotationMediaLoading = ({ y, media, className, onClick, onDoubleClick }) => { +export const AnnotationMediaLoading = ({ y, annotation, media, className, onClick, onDoubleClick }) => { if (!media) { return (