Skip to content
Snippets Groups Projects
Commit e79e1bd6 authored by john's avatar john
Browse files

indicate that a chapter has content

parent 8fb3827d
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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
}
......
......@@ -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}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment