import React, { Component } from 'react' import { connect } from 'react-redux' import actions from 'app/actions' import { ROMAN_NUMERALS } from 'app/constants' import { pad } from 'app/utils' import { thumbnailURL } from 'app/utils/annotation.utils' import { PlayIcon } from '../nav/viewer.icons' class ChecklistContent extends Component { handleMediaSelection(section, mediaItem, i) { if (this.props.onlyEnableFirstSection) return // when clicking a work in the checklist, // if it's the first work in the section, seek to the beginning of the section // OTHERWISE seek to the work itself. might have to add this as another option on sections // since the first "work" in Animism pt 1 starts about a minute in... if (i === 0 && section.index !== 0) { actions.viewer.hideNavComponent('checklist') actions.viewer.seekToSection(section) } else { actions.viewer.seekToMediaItem(section, mediaItem) } } render() { const { sections, checklistSection } = this.props let mediaIndex = 1 return (
{sections.map(section => { if ((checklistSection !== "all" && section.index !== checklistSection) || !section.media.length) { return
} return (
{section.media.map((mediaItem, i) => (
this.handleMediaSelection(section, mediaItem, i)} >
{pad(mediaIndex++, 2)}
{ROMAN_NUMERALS[section.index]}
{section.title}
{mediaItem.media.author}
{mediaItem.media.pre_title && (mediaItem.media.pre_title + ' ')} {mediaItem.media.title} {mediaItem.media.post_title && (' ' + mediaItem.media.post_title)}
{mediaItem.media.title.indexOf(String(mediaItem.media.date)) !== -1 && mediaItem.media.date}
{mediaItem.media.medium} {mediaItem.media.settings.duration && (', ' + mediaItem.media.settings.duration)}
{mediaItem.media.title} {mediaItem.type === 'video' && {PlayIcon} }
))}
) })}
) } } const mapStateToProps = state => ({ sections: state.viewer.sections, onlyEnableFirstSection: state.viewer.onlyEnableFirstSection, }) export default connect(mapStateToProps)(ChecklistContent)