From decfe90c53417c0b2815d49b32ccf4878ca7e7e0 Mon Sep 17 00:00:00 2001 From: john <johnbarlas39@gmail.com> Date: Thu, 15 Dec 2016 21:31:18 +0200 Subject: [PATCH] save the converted text to the db --- .../BookBuilder/Chapter/ChapterTitle.jsx | 57 ++++++++++--------- .../BookBuilder/Chapter/UploadButton.jsx | 10 ++-- .../SimpleEditor/SimpleEditorWrapper.jsx | 1 + 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/app/components/BookBuilder/Chapter/ChapterTitle.jsx b/app/components/BookBuilder/Chapter/ChapterTitle.jsx index 45ae99d..bd531a3 100644 --- a/app/components/BookBuilder/Chapter/ChapterTitle.jsx +++ b/app/components/BookBuilder/Chapter/ChapterTitle.jsx @@ -47,25 +47,21 @@ class ChapterTitle extends React.Component { ) } - render () { - const { - chapter, - isRenaming, - isRenameEmpty, - isUploadInProgress, - onClickRename, - onSaveRename, - title, - type, - update - } = this.props + renderUploadIndicator () { + const { isUploadInProgress } = this.props - const hasContent = this.renderHasContent() + if (!isUploadInProgress) return null - let titleArea + return ( + <i className={styles['animate-flicker'] + ' fa fa-upload'} /> + ) + } + + renderTitle () { + const { chapter, isRenaming, onClickRename, onSaveRename, title, type, update } = this.props if (type === 'chapter' || type === 'part') { - titleArea = ( + return ( <Title isRenaming={isRenaming} onClickRename={onClickRename} @@ -74,7 +70,7 @@ class ChapterTitle extends React.Component { /> ) } else if (type === 'component') { - titleArea = ( + return ( <DropdownTitle chapter={chapter} title={title} @@ -82,26 +78,31 @@ class ChapterTitle extends React.Component { /> ) } + } - let uploadIndicator + renderError () { + const { isRenameEmpty } = this.props - if (isUploadInProgress) { - uploadIndicator = ( - // <span className={styles['animate-flicker']}>Uploading...</span> - <i className={styles['animate-flicker'] + ' fa fa-upload'} /> - ) - } + return ( + <RenameEmptyError + isRenameEmpty={isRenameEmpty} + /> + ) + } + + render () { + const hasContent = this.renderHasContent() + const title = this.renderTitle() + const uploadIndicator = this.renderUploadIndicator() + const renameEmptyError = this.renderError() return ( <div className={styles.chapterTitle}> { hasContent } - { titleArea } + { title } { uploadIndicator } - - <RenameEmptyError - isRenameEmpty={isRenameEmpty} - /> + { renameEmptyError } <div className={styles.separator} /> diff --git a/app/components/BookBuilder/Chapter/UploadButton.jsx b/app/components/BookBuilder/Chapter/UploadButton.jsx index 85b91cd..f3bd9ea 100644 --- a/app/components/BookBuilder/Chapter/UploadButton.jsx +++ b/app/components/BookBuilder/Chapter/UploadButton.jsx @@ -14,15 +14,17 @@ export class UploadButton extends React.Component { const { chapter, convertFile, - toggleUpload - // update + toggleUpload, + update } = this.props toggleUpload() convertFile(file).then(response => { - console.log(response) - console.log(chapter) + // console.log(response) + // console.log(chapter) + chapter.source = response.converted + update(chapter) toggleUpload() }) } diff --git a/app/components/SimpleEditor/SimpleEditorWrapper.jsx b/app/components/SimpleEditor/SimpleEditorWrapper.jsx index 05a0989..08233a0 100644 --- a/app/components/SimpleEditor/SimpleEditorWrapper.jsx +++ b/app/components/SimpleEditor/SimpleEditorWrapper.jsx @@ -100,6 +100,7 @@ export class SimpleEditorWrapper extends React.Component { render () { const { book, fragment, history, user } = this.props + // console.log(fragment) return ( <SimpleEditor -- GitLab