diff --git a/app/components/SimpleEditor/Editor.js b/app/components/SimpleEditor/Editor.js index 72fc9d5a42b71bd702e80fff5c222c66827857eb..3220e5828efc7ddc71d184865fdb5ab722c7c571 100644 --- a/app/components/SimpleEditor/Editor.js +++ b/app/components/SimpleEditor/Editor.js @@ -30,7 +30,8 @@ class Editor extends ProseEditor { 'trackChangesUpdate': function () { this.updateTrackChange() }, 'trackChangesViewToggle': function () { this.trackChangesViewToggle() }, // 'changesNotSaved': function () { this.changesNotSaved() } - 'changesNotSaved': this.changesNotSaved + 'changesNotSaved': this.changesNotSaved, + 'closeModal': this.closeModal }) } @@ -231,6 +232,10 @@ class Editor extends ProseEditor { this.refs.contentPanel.scrollTo(nodeId) } + closeModal () { + this.extendState({ changesNotSaved: false }) + } + toggleCommentsArea (show) { var self = this diff --git a/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js b/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js index 8462b7eca083efc5ba2581744d7de25b0bbe37ac..c92e365e8c5eecf052c35c26736b4c977dc3916d 100644 --- a/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js +++ b/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js @@ -1,5 +1,5 @@ import { each } from 'lodash' -import { Modal } from 'substance' +import { Modal, FontAwesomeIcon as Icon } from 'substance' class ModalWarning extends Modal { constructor (props) { @@ -14,9 +14,14 @@ class ModalWarning extends Modal { let el = $$('div') .addClass('sc-modal') + const closeButton = $$(Icon, { icon: 'fa-close' }) + .addClass('sc-close-modal') + .on('click', this._closeModal) + const modalHeader = $$('div') .addClass('sc-modal-header') .append('Unsaved Content') + .append(closeButton) const modalMessage = $$('div') .addClass('sc-modal-body') @@ -58,14 +63,18 @@ class ModalWarning extends Modal { this.backButton = args.back } + _closeModal () { + this.send('closeModal') + } + _saveExitWriter () { - this.rerender() this.context.editor.editorSession.save() if (this.backButton) { setTimeout(() => { this.context.editor.props.history.go(-2) }, 200) } else { setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200) } + this._closeModal() } // TODO: Hack Check why cannot rerender editor so can push to url @@ -82,6 +91,7 @@ class ModalWarning extends Modal { // TODO: Hack Check why cannot rerender editor so can push to url setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200) } + this._closeModal() } } diff --git a/app/components/SimpleEditor/elements/modal_warning/modalWarning.scss b/app/components/SimpleEditor/elements/modal_warning/modalWarning.scss index 8652daeb960443c510771ed01a06d04f3ea80c67..071738904712d3653bdc97d6814b94dc4ae1300e 100644 --- a/app/components/SimpleEditor/elements/modal_warning/modalWarning.scss +++ b/app/components/SimpleEditor/elements/modal_warning/modalWarning.scss @@ -25,6 +25,14 @@ $white: #fff; line-height: 32px; } + .sc-close-modal { + cursor: pointer; + float: right; + font-size: 16px; + font-weight: normal; + margin-top: 10px; + } + .sc-modal-body { padding: 20px 0; }