mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
prepare alpha.5 (remain work: MD preview, keybind)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import api from 'boost/api'
|
||||
import linkState from 'boost/linkState'
|
||||
import FolderMark from 'boost/components/FolderMark'
|
||||
import store from 'boost/store'
|
||||
import { updateFolder, destroyFolder } from 'boost/actions'
|
||||
|
||||
const IDLE = 'IDLE'
|
||||
const EDIT = 'EDIT'
|
||||
@@ -12,22 +13,21 @@ export default class FolderRow extends React.Component {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
mode: IDLE,
|
||||
name: props.folder.name,
|
||||
public: props.folder.public
|
||||
mode: IDLE
|
||||
}
|
||||
}
|
||||
|
||||
handleCancelButtonClick (e) {
|
||||
this.setState({
|
||||
mode: IDLE,
|
||||
name: this.props.folder.name,
|
||||
public: this.props.folder.public
|
||||
mode: IDLE
|
||||
})
|
||||
}
|
||||
|
||||
handleEditButtonClick (e) {
|
||||
this.setState({mode: EDIT})
|
||||
this.setState({
|
||||
mode: EDIT,
|
||||
name: this.props.folder.name
|
||||
})
|
||||
}
|
||||
|
||||
handleDeleteButtonClick (e) {
|
||||
@@ -39,31 +39,21 @@ export default class FolderRow extends React.Component {
|
||||
}
|
||||
|
||||
handleSaveButtonClick (e) {
|
||||
let { folder } = this.props
|
||||
let input = {
|
||||
name: this.state.name,
|
||||
public: !!parseInt(this.state.public, 10)
|
||||
name: this.state.name
|
||||
}
|
||||
Object.assign(folder, input)
|
||||
|
||||
api.updateFolder(this.props.folder.id, input)
|
||||
.then(res => {
|
||||
console.log(res.body)
|
||||
this.setState({mode: IDLE})
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.status != null) throw err
|
||||
else console.error(err)
|
||||
})
|
||||
store.dispatch(updateFolder(folder))
|
||||
this.setState({
|
||||
mode: IDLE
|
||||
})
|
||||
}
|
||||
|
||||
handleDeleteConfirmButtonClick (e) {
|
||||
api.destroyFolder(this.props.folder.id)
|
||||
.then(res => {
|
||||
console.log(res.body)
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.status != null) throw err
|
||||
else console.error(err)
|
||||
})
|
||||
let { folder } = this.props
|
||||
store.dispatch(destroyFolder(folder.key))
|
||||
}
|
||||
|
||||
render () {
|
||||
@@ -76,12 +66,6 @@ export default class FolderRow extends React.Component {
|
||||
<div className='folderName'>
|
||||
<input valueLink={this.linkState('name')} type='text'/>
|
||||
</div>
|
||||
<div className='folderPublic'>
|
||||
<select value={this.state.public} onChange={e => this.handleFolderPublicChange(e)}>
|
||||
<option value='0'>Private</option>
|
||||
<option value='1'>Public</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className='folderControl'>
|
||||
<button onClick={e => this.handleSaveButtonClick(e)} className='primary'>Save</button>
|
||||
<button onClick={e => this.handleCancelButtonClick(e)}>Cancel</button>
|
||||
@@ -102,8 +86,7 @@ export default class FolderRow extends React.Component {
|
||||
default:
|
||||
return (
|
||||
<div className='FolderRow'>
|
||||
<div className='folderName'><FolderMark id={folder.id}/> {folder.name}</div>
|
||||
<div className='folderPublic'>{folder.public ? 'Public' : 'Private'}</div>
|
||||
<div className='folderName'><FolderMark color={folder.color}/> {folder.name}</div>
|
||||
<div className='folderControl'>
|
||||
<button onClick={e => this.handleEditButtonClick(e)}><i className='fa fa-fw fa-edit'/></button>
|
||||
<button onClick={e => this.handleDeleteButtonClick(e)}><i className='fa fa-fw fa-close'/></button>
|
||||
|
||||
Reference in New Issue
Block a user