diff --git a/app/components/BookBuilder/Chapter/ChapterTitle.jsx b/app/components/BookBuilder/Chapter/ChapterTitle.jsx index c0abc153d41d71b166127251562dea776b07fd23..ac4fee9cf3b7770ff64207dd2f5bf029077c8ddc 100644 --- a/app/components/BookBuilder/Chapter/ChapterTitle.jsx +++ b/app/components/BookBuilder/Chapter/ChapterTitle.jsx @@ -7,10 +7,49 @@ import Title from './Title' import styles from '../styles/bookBuilder.local.scss' class ChapterTitle extends React.Component { + renderHasContent () { + const { chapter, type } = this.props + const source = chapter.source + const hasContent = source.trim().length > 0 + + if (!hasContent) return null + + // TODO -- move styles to classes (after css refactor) + let marginTop + switch (type) { + case 'part': + marginTop = '4px' + break + case 'chapter': + marginTop = '2px' + break + default: + marginTop = '5px' + break + } + + const styles = { + 'color': '#3e644b', + 'float': 'left', + 'font-size': '14px', + 'margin-top': marginTop, + 'margin-right': '7px' + } + + const hoverTitle = 'This ' + type + ' has content' + + return ( + <i + className='fa fa-check-circle' + style={styles} + title={hoverTitle} + /> + ) + } + render () { const { chapter, - division, isRenaming, isRenameEmpty, isUploadInProgress, @@ -21,6 +60,8 @@ class ChapterTitle extends React.Component { update } = this.props + const hasContent = this.renderHasContent() + let titleArea if (type === 'chapter' || type === 'part') { @@ -36,7 +77,6 @@ class ChapterTitle extends React.Component { titleArea = ( <DropdownTitle chapter={chapter} - division={division} title={title} update={update} /> @@ -54,6 +94,7 @@ class ChapterTitle extends React.Component { return ( <div className={styles.chapterTitle}> + { hasContent } { titleArea } { uploadIndicator } @@ -70,7 +111,6 @@ class ChapterTitle extends React.Component { ChapterTitle.propTypes = { chapter: React.PropTypes.object.isRequired, - division: React.PropTypes.string.isRequired, isRenaming: React.PropTypes.bool.isRequired, isRenameEmpty: React.PropTypes.bool.isRequired, isUploadInProgress: React.PropTypes.bool.isRequired, diff --git a/app/components/BookBuilder/Chapter/DropdownTitle.jsx b/app/components/BookBuilder/Chapter/DropdownTitle.jsx index fb84c654390734b74a8e56c4817cb3749dbf80cc..627c1f13734b62f9c75e470036628248cbeb15b0 100644 --- a/app/components/BookBuilder/Chapter/DropdownTitle.jsx +++ b/app/components/BookBuilder/Chapter/DropdownTitle.jsx @@ -73,7 +73,9 @@ class DropdownTitle extends React.Component { } getDropdownOptions () { - const { division } = this.props + const { chapter } = this.props + const division = chapter.division + return config.dropdownValues[division] } @@ -192,7 +194,6 @@ class DropdownTitle extends React.Component { DropdownTitle.propTypes = { chapter: React.PropTypes.object.isRequired, - division: React.PropTypes.string.isRequired, title: React.PropTypes.string.isRequired, update: React.PropTypes.func.isRequired } diff --git a/app/components/BookBuilder/Chapter/FirstRow.jsx b/app/components/BookBuilder/Chapter/FirstRow.jsx index 8b4c9caa458db01e1c54fdb76a23d564fa3d3cf4..367c7bc75d1e4e45a90f88f5e78d94bbfbbccce7 100644 --- a/app/components/BookBuilder/Chapter/FirstRow.jsx +++ b/app/components/BookBuilder/Chapter/FirstRow.jsx @@ -43,13 +43,11 @@ class ChapterFirstRow extends React.Component { render () { const { book, chapter, isUploadInProgress, outerContainer, remove, roles, title, type, update } = this.props const { isRenameEmpty, isRenamingTitle } = this.state - const division = chapter.division return ( <span> <ChapterTitle chapter={chapter} - division={division} isRenaming={isRenamingTitle} isRenameEmpty={isRenameEmpty} isUploadInProgress={isUploadInProgress}