Skip to content
Snippets Groups Projects
Commit 35df8470 authored by chris's avatar chris
Browse files

add close only funcionality to modal

parent 72fa9a3b
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,8 @@ class Editor extends ProseEditor { ...@@ -30,7 +30,8 @@ class Editor extends ProseEditor {
'trackChangesUpdate': function () { this.updateTrackChange() }, 'trackChangesUpdate': function () { this.updateTrackChange() },
'trackChangesViewToggle': function () { this.trackChangesViewToggle() }, 'trackChangesViewToggle': function () { this.trackChangesViewToggle() },
// 'changesNotSaved': function () { this.changesNotSaved() } // 'changesNotSaved': function () { this.changesNotSaved() }
'changesNotSaved': this.changesNotSaved 'changesNotSaved': this.changesNotSaved,
'closeModal': this.closeModal
}) })
} }
...@@ -231,6 +232,10 @@ class Editor extends ProseEditor { ...@@ -231,6 +232,10 @@ class Editor extends ProseEditor {
this.refs.contentPanel.scrollTo(nodeId) this.refs.contentPanel.scrollTo(nodeId)
} }
closeModal () {
this.extendState({ changesNotSaved: false })
}
toggleCommentsArea (show) { toggleCommentsArea (show) {
var self = this var self = this
......
import { each } from 'lodash' import { each } from 'lodash'
import { Modal } from 'substance' import { Modal, FontAwesomeIcon as Icon } from 'substance'
class ModalWarning extends Modal { class ModalWarning extends Modal {
constructor (props) { constructor (props) {
...@@ -14,9 +14,14 @@ class ModalWarning extends Modal { ...@@ -14,9 +14,14 @@ class ModalWarning extends Modal {
let el = $$('div') let el = $$('div')
.addClass('sc-modal') .addClass('sc-modal')
const closeButton = $$(Icon, { icon: 'fa-close' })
.addClass('sc-close-modal')
.on('click', this._closeModal)
const modalHeader = $$('div') const modalHeader = $$('div')
.addClass('sc-modal-header') .addClass('sc-modal-header')
.append('Unsaved Content') .append('Unsaved Content')
.append(closeButton)
const modalMessage = $$('div') const modalMessage = $$('div')
.addClass('sc-modal-body') .addClass('sc-modal-body')
...@@ -58,14 +63,18 @@ class ModalWarning extends Modal { ...@@ -58,14 +63,18 @@ class ModalWarning extends Modal {
this.backButton = args.back this.backButton = args.back
} }
_closeModal () {
this.send('closeModal')
}
_saveExitWriter () { _saveExitWriter () {
this.rerender()
this.context.editor.editorSession.save() this.context.editor.editorSession.save()
if (this.backButton) { if (this.backButton) {
setTimeout(() => { this.context.editor.props.history.go(-2) }, 200) setTimeout(() => { this.context.editor.props.history.go(-2) }, 200)
} else { } else {
setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200) setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200)
} }
this._closeModal()
} }
// TODO: Hack Check why cannot rerender editor so can push to url // TODO: Hack Check why cannot rerender editor so can push to url
...@@ -82,6 +91,7 @@ class ModalWarning extends Modal { ...@@ -82,6 +91,7 @@ class ModalWarning extends Modal {
// TODO: Hack Check why cannot rerender editor so can push to url // TODO: Hack Check why cannot rerender editor so can push to url
setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200) setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200)
} }
this._closeModal()
} }
} }
......
...@@ -25,6 +25,14 @@ $white: #fff; ...@@ -25,6 +25,14 @@ $white: #fff;
line-height: 32px; line-height: 32px;
} }
.sc-close-modal {
cursor: pointer;
float: right;
font-size: 16px;
font-weight: normal;
margin-top: 10px;
}
.sc-modal-body { .sc-modal-body {
padding: 20px 0; padding: 20px 0;
} }
......
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