1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

add folder create

This commit is contained in:
Rokt33r
2015-10-24 21:32:53 +09:00
parent 911cfd8642
commit 5ed2dfccd1
5 changed files with 115 additions and 2 deletions

View File

@@ -1,8 +1,18 @@
import React, { PropTypes } from 'react'
import _ from 'lodash'
import FolderRow from './FolderRow'
import linkState from 'boost/linkState'
import api from 'boost/api'
export default class FolderSettingTab extends React.Component {
constructor (props) {
super(props)
this.state = {
name: '',
public: 0
}
}
getCurrentTeam (props) {
if (props == null) props = this.props
@@ -13,6 +23,32 @@ export default class FolderSettingTab extends React.Component {
this.props.switchTeam(e.target.value)
}
handleFolderPublicChange (e) {
this.setState({public: e.target.value})
}
handleSaveButtonClick (e) {
let team = this.getCurrentTeam()
let input = {
UserId: team.id,
name: this.state.name,
public: !!parseInt(this.state.public, 10)
}
api.createFolder(input)
.then(res => {
console.log(res.body)
this.setState({
name: '',
public: 0
})
})
.catch(err => {
if (err.status != null) throw err
else console.error(err)
})
}
renderTeamOptions () {
return this.props.teams.map(team => {
return (
@@ -49,6 +85,20 @@ export default class FolderSettingTab extends React.Component {
<div className='folderControl'>Edit/Delete</div>
</div>
{folderElements}
<div className='newFolder'>
<div className='folderName'>
<input valueLink={this.linkState('name')} type='text' placeholder='New Folder'/>
</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'>Add</button>
</div>
</div>
</div>
</div>
</div>
@@ -61,3 +111,5 @@ FolderSettingTab.propTypes = {
teams: PropTypes.array,
switchTeam: PropTypes.func
}
FolderSettingTab.prototype.linkState = linkState