From e79e1bd6e54cfb00d5b06f962da19cde83663de3 Mon Sep 17 00:00:00 2001 From: john <johnbarlas39@gmail.com> Date: Thu, 15 Dec 2016 17:57:19 +0200 Subject: [PATCH] indicate that a chapter has content --- .../BookBuilder/Chapter/ChapterTitle.jsx | 46 +++++++++++++++++-- .../BookBuilder/Chapter/DropdownTitle.jsx | 5 +- .../BookBuilder/Chapter/FirstRow.jsx | 2 - 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/app/components/BookBuilder/Chapter/ChapterTitle.jsx b/app/components/BookBuilder/Chapter/ChapterTitle.jsx index c0abc15..ac4fee9 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 fb84c65..627c1f1 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 8b4c9ca..367c7bc 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} -- GitLab