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' ...@@ -7,10 +7,49 @@ import Title from './Title'
import styles from '../styles/bookBuilder.local.scss' import styles from '../styles/bookBuilder.local.scss'
class ChapterTitle extends React.Component { 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 () { render () {
const { const {
chapter, chapter,
division,
isRenaming, isRenaming,
isRenameEmpty, isRenameEmpty,
isUploadInProgress, isUploadInProgress,
...@@ -21,6 +60,8 @@ class ChapterTitle extends React.Component { ...@@ -21,6 +60,8 @@ class ChapterTitle extends React.Component {
update update
} = this.props } = this.props
const hasContent = this.renderHasContent()
let titleArea let titleArea
if (type === 'chapter' || type === 'part') { if (type === 'chapter' || type === 'part') {
...@@ -36,7 +77,6 @@ class ChapterTitle extends React.Component { ...@@ -36,7 +77,6 @@ class ChapterTitle extends React.Component {
titleArea = ( titleArea = (
<DropdownTitle <DropdownTitle
chapter={chapter} chapter={chapter}
division={division}
title={title} title={title}
update={update} update={update}
/> />
...@@ -54,6 +94,7 @@ class ChapterTitle extends React.Component { ...@@ -54,6 +94,7 @@ class ChapterTitle extends React.Component {
return ( return (
<div className={styles.chapterTitle}> <div className={styles.chapterTitle}>
{ hasContent }
{ titleArea } { titleArea }
{ uploadIndicator } { uploadIndicator }
...@@ -70,7 +111,6 @@ class ChapterTitle extends React.Component { ...@@ -70,7 +111,6 @@ class ChapterTitle extends React.Component {
ChapterTitle.propTypes = { ChapterTitle.propTypes = {
chapter: React.PropTypes.object.isRequired, chapter: React.PropTypes.object.isRequired,
division: React.PropTypes.string.isRequired,
isRenaming: React.PropTypes.bool.isRequired, isRenaming: React.PropTypes.bool.isRequired,
isRenameEmpty: React.PropTypes.bool.isRequired, isRenameEmpty: React.PropTypes.bool.isRequired,
isUploadInProgress: React.PropTypes.bool.isRequired, isUploadInProgress: React.PropTypes.bool.isRequired,
......
...@@ -73,7 +73,9 @@ class DropdownTitle extends React.Component { ...@@ -73,7 +73,9 @@ class DropdownTitle extends React.Component {
} }
getDropdownOptions () { getDropdownOptions () {
const { division } = this.props const { chapter } = this.props
const division = chapter.division
return config.dropdownValues[division] return config.dropdownValues[division]
} }
...@@ -192,7 +194,6 @@ class DropdownTitle extends React.Component { ...@@ -192,7 +194,6 @@ class DropdownTitle extends React.Component {
DropdownTitle.propTypes = { DropdownTitle.propTypes = {
chapter: React.PropTypes.object.isRequired, chapter: React.PropTypes.object.isRequired,
division: React.PropTypes.string.isRequired,
title: React.PropTypes.string.isRequired, title: React.PropTypes.string.isRequired,
update: React.PropTypes.func.isRequired update: React.PropTypes.func.isRequired
} }
......
...@@ -43,13 +43,11 @@ class ChapterFirstRow extends React.Component { ...@@ -43,13 +43,11 @@ class ChapterFirstRow extends React.Component {
render () { render () {
const { book, chapter, isUploadInProgress, outerContainer, remove, roles, title, type, update } = this.props const { book, chapter, isUploadInProgress, outerContainer, remove, roles, title, type, update } = this.props
const { isRenameEmpty, isRenamingTitle } = this.state const { isRenameEmpty, isRenamingTitle } = this.state
const division = chapter.division
return ( return (
<span> <span>
<ChapterTitle <ChapterTitle
chapter={chapter} chapter={chapter}
division={division}
isRenaming={isRenamingTitle} isRenaming={isRenamingTitle}
isRenameEmpty={isRenameEmpty} isRenameEmpty={isRenameEmpty}
isUploadInProgress={isUploadInProgress} 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