{folderName}
by {activeArticle.User.profileName}
Created {moment(activeArticle.createdAt).format('YYYY/MM/DD')}
Updated {moment(activeArticle.updatedAt).format('YYYY/MM/DD')}
{tags}
)
}
{activeArticle.title}
{activeArticle.mode === 'markdown'
?
:
}
)
}
handleCancelButtonClick (e) {
this.props.dispatch(switchMode(IDLE_MODE))
}
handleSaveButtonClick (e) {
let { activeArticle } = this.props
if (activeArticle.id == null) this.saveAsNew()
else this.save()
}
saveAsNew () {
let { dispatch, activeUser } = this.props
let article = this.state.article
let newArticle = Object.assign({}, article)
article.tags = article.Tags
api.createArticle(article)
.then(res => {
console.log(res.body)
})
.catch(err => {
// connect failed need to queue data
if (err.code === 'ECONNREFUSED') {
return
}
if (err.status != null) throw err
else console.log(err)
})
newArticle.status = UNSYNCED
newArticle.Tags = newArticle.Tags.map(tag => { return {name: tag} })
dispatch(updateArticle(activeUser.id, newArticle))
dispatch(switchMode(IDLE_MODE))
dispatch(switchArticle(article.id))
}
save () {
let { dispatch, activeUser } = this.props
let article = this.state.article
let newArticle = Object.assign({}, article)
article.tags = article.Tags
api.saveArticle(article)
.then(res => {
console.log(res.body)
})
.catch(err => {
// connect failed need to queue data
if (err.code === 'ECONNREFUSED') {
return
}
if (err.status != null) throw err
else console.log(err)
})
newArticle.status = UNSYNCED
newArticle.Tags = newArticle.Tags.map(tag => { return {name: tag} })
dispatch(updateArticle(activeUser.id, newArticle))
dispatch(switchMode(IDLE_MODE))
dispatch(switchArticle(article.id))
}
handleFolderIdChange (value) {
let article = this.state.article
article.FolderId = value
this.setState({article: article})
}
handleTagsChange (tag, tags) {
tags = uniq(tags, function (tag) {
return tag.value
})
var article = this.state.article
article.Tags = tags.map(function (tag) {
return tag.value
})
this.setState({article: article})
}
handleModeChange (value) {
let article = this.state.article
article.mode = value
this.setState({article: article})
}
handleContentChange (e, value) {
let article = this.state.article
article.content = value
this.setState({article: article})
}
renderEdit () {
let { activeUser } = this.props
let folderOptions = activeUser.Folders.map(folder => {
return {
label: folder.name,
value: folder.id
}
})
return (