2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
|
|
import Icon from '../Icon'
|
|
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
|
|
|
|
|
export default class EditPlaylistModal extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
this.state = {
|
2017-07-13 07:53:00 +12:00
|
|
|
error: null,
|
2016-11-14 17:32:36 +13:00
|
|
|
name: this.props.data.name,
|
2017-07-13 07:53:00 +12:00
|
|
|
description: (this.props.data.description ? this.props.data.description : ''),
|
2017-07-13 15:26:30 +12:00
|
|
|
is_public: this.props.data.is_public,
|
|
|
|
|
is_collaborative: this.props.data.is_collaborative
|
2016-11-14 17:32:36 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
savePlaylist(e){
|
|
|
|
|
e.preventDefault();
|
2017-07-13 07:53:00 +12:00
|
|
|
|
|
|
|
|
if (!this.state.name || this.state.name == ''){
|
|
|
|
|
this.setState({error: 'Name is required'})
|
|
|
|
|
return false
|
|
|
|
|
} else {
|
2017-07-13 15:26:30 +12:00
|
|
|
this.props.uiActions.savePlaylist(this.props.data.uri, this.state.name, this.state.description, this.state.is_public, this.state.is_collaborative)
|
2017-07-13 07:53:00 +12:00
|
|
|
this.props.uiActions.closeModal()
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderFields(){
|
|
|
|
|
switch (helpers.uriSource(this.props.data.uri)){
|
|
|
|
|
|
|
|
|
|
case 'spotify':
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2017-07-13 15:26:30 +12:00
|
|
|
<div className="field text">
|
|
|
|
|
<span className="label">Name</span>
|
2017-07-13 07:53:00 +12:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({ name: e.target.value })}
|
|
|
|
|
value={ this.state.name } />
|
|
|
|
|
</div>
|
2017-07-13 15:26:30 +12:00
|
|
|
<div className="field text">
|
|
|
|
|
<span className="label">Description</span>
|
2017-07-13 07:53:00 +12:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({ description: e.target.value })}
|
|
|
|
|
value={ this.state.description } />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="field checkbox white">
|
2017-07-13 15:26:30 +12:00
|
|
|
<span className="label">Options</span>
|
2017-07-13 07:53:00 +12:00
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="playlist_private"
|
|
|
|
|
checked={ this.state.is_public }
|
|
|
|
|
onChange={ e => this.setState({ is_public: !this.state.is_public })} />
|
|
|
|
|
<span className="label">Public</span>
|
|
|
|
|
</label>
|
2017-07-13 15:26:30 +12:00
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="is_collaborative"
|
|
|
|
|
checked={ this.state.is_collaborative }
|
|
|
|
|
onChange={ e => this.setState({ is_collaborative: !this.state.is_collaborative })} />
|
|
|
|
|
<span className="label">Collaborative</span>
|
|
|
|
|
</label>
|
2017-07-13 07:53:00 +12:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="field">
|
2017-07-13 15:26:30 +12:00
|
|
|
<span className="label">Name</span>
|
2017-07-13 07:53:00 +12:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({ name: e.target.value })}
|
|
|
|
|
value={ this.state.name } />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
2016-11-14 17:32:36 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2017-06-21 09:16:26 +12:00
|
|
|
<h1>Edit playlist</h1>
|
2017-07-13 07:53:00 +12:00
|
|
|
{this.state.error ? <h3 className="red-text">{this.state.error}</h3> : null}
|
2016-11-14 17:32:36 +13:00
|
|
|
<form onSubmit={(e) => this.savePlaylist(e)}>
|
2017-07-13 07:53:00 +12:00
|
|
|
|
|
|
|
|
{this.renderFields()}
|
|
|
|
|
|
2017-02-05 19:57:29 +13:00
|
|
|
<div className="actions centered-text">
|
2017-07-13 07:53:00 +12:00
|
|
|
<button type="submit" className="primary wide">Save</button>
|
2017-02-05 19:57:29 +13:00
|
|
|
</div>
|
2016-11-14 17:32:36 +13:00
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|