2016-11-14 17:32:36 +13:00
|
|
|
|
2018-07-09 19:09:12 +12:00
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
|
import { Link } from 'react-router'
|
|
|
|
|
import ReactGA from 'react-ga'
|
|
|
|
|
|
|
|
|
|
import Modal from './Modal';
|
|
|
|
|
import Icon from '../../components/Icon';
|
|
|
|
|
import * as coreActions from '../../services/core/actions'
|
|
|
|
|
import * as uiActions from '../../services/ui/actions'
|
2018-02-01 08:06:40 +13:00
|
|
|
import * as helpers from '../../helpers';
|
2016-11-14 17:32:36 +13:00
|
|
|
|
2018-07-09 19:09:12 +12:00
|
|
|
class CreatePlaylist extends React.Component{
|
2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
this.state = {
|
|
|
|
|
name: '',
|
2017-07-13 15:26:30 +12:00
|
|
|
description: '',
|
2016-11-14 17:32:36 +13:00
|
|
|
scheme: 'spotify',
|
2017-07-13 15:26:30 +12:00
|
|
|
is_public: true,
|
|
|
|
|
is_collaborative: false
|
2016-11-14 17:32:36 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 16:48:41 +12:00
|
|
|
componentDidMount(){
|
|
|
|
|
this.props.uiActions.setWindowTitle("Create playlist");
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
createPlaylist(e){
|
2017-07-13 15:26:30 +12:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
if (!this.state.name || this.state.name == ''){
|
|
|
|
|
this.setState({error: 'Name is required'})
|
|
|
|
|
return false
|
|
|
|
|
} else {
|
2018-07-09 19:09:12 +12:00
|
|
|
this.props.coreActions.createPlaylist(
|
|
|
|
|
this.state.scheme,
|
|
|
|
|
this.state.name,
|
|
|
|
|
this.state.description,
|
|
|
|
|
this.state.is_public,
|
|
|
|
|
this.state.is_collaborative
|
|
|
|
|
);
|
|
|
|
|
window.history.back();
|
2017-07-13 15:26:30 +12:00
|
|
|
}
|
2016-11-14 17:32:36 +13:00
|
|
|
|
2017-07-13 15:26:30 +12:00
|
|
|
return false
|
2016-11-14 17:32:36 +13:00
|
|
|
}
|
|
|
|
|
|
2017-07-14 08:57:53 +12:00
|
|
|
renderFields(){
|
|
|
|
|
switch (this.state.scheme){
|
|
|
|
|
|
|
|
|
|
case 'spotify':
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="field text">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">Name</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({ name: e.target.value })}
|
|
|
|
|
value={ this.state.name } />
|
|
|
|
|
</div>
|
2017-07-14 08:57:53 +12:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="field text">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">Description</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({ description: e.target.value })}
|
|
|
|
|
|
|
|
|
|
value={ this.state.description } />
|
|
|
|
|
</div>
|
2017-07-14 08:57:53 +12:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="field checkbox white">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">
|
2018-05-24 21:37:41 +12:00
|
|
|
Options
|
|
|
|
|
</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="is_public"
|
|
|
|
|
checked={ this.state.is_public }
|
|
|
|
|
onChange={ e => this.setState({ is_public: !this.state.is_public })} />
|
|
|
|
|
<span className="label">Public</span>
|
|
|
|
|
</label>
|
|
|
|
|
<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>
|
|
|
|
|
</div>
|
2017-07-14 08:57:53 +12:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="field text">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">Name</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({ name: e.target.value })}
|
|
|
|
|
value={ this.state.name } />
|
|
|
|
|
</div>
|
2017-07-14 08:57:53 +12:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
render(){
|
|
|
|
|
return (
|
2018-07-13 16:48:41 +12:00
|
|
|
<Modal className="modal--create-playlist">
|
2017-06-21 09:16:26 +12:00
|
|
|
<h1>Create playlist</h1>
|
2016-11-14 17:32:36 +13:00
|
|
|
<form onSubmit={(e) => this.createPlaylist(e)}>
|
2017-07-13 15:26:30 +12:00
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
<div className="field radio white">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">
|
2018-05-24 21:37:41 +12:00
|
|
|
Provider
|
|
|
|
|
</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="radio"
|
|
|
|
|
name="scheme"
|
|
|
|
|
value="spotify"
|
|
|
|
|
checked={ this.state.scheme == 'spotify' }
|
|
|
|
|
onChange={ e => this.setState({ scheme: e.target.value })} />
|
|
|
|
|
<span className="label">Spotify</span>
|
|
|
|
|
</label>
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="radio"
|
|
|
|
|
name="scheme"
|
|
|
|
|
value="m3u"
|
|
|
|
|
checked={ this.state.scheme == 'm3u' }
|
|
|
|
|
onChange={ e => this.setState({ scheme: e.target.value })} />
|
|
|
|
|
<span className="label">Mopidy</span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
2016-11-14 17:32:36 +13:00
|
|
|
</div>
|
2017-07-14 08:57:53 +12:00
|
|
|
|
|
|
|
|
{this.renderFields()}
|
|
|
|
|
|
2017-02-05 19:57:29 +13:00
|
|
|
<div className="actions centered-text">
|
2018-02-01 08:06:40 +13:00
|
|
|
<button type="submit" className="primary large">Create playlist</button>
|
2017-02-05 19:57:29 +13:00
|
|
|
</div>
|
2017-07-14 08:57:53 +12:00
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
</form>
|
2018-07-09 19:09:12 +12:00
|
|
|
</Modal>
|
2016-11-14 17:32:36 +13:00
|
|
|
)
|
|
|
|
|
}
|
2018-07-09 19:09:12 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
coreActions: bindActionCreators(coreActions, dispatch),
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(CreatePlaylist)
|