Modal blur bg; Editing/creating playlists with descriptions and collab
This commit is contained in:
@ -205,11 +205,15 @@ class App extends React.Component{
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<Sidebar />
|
||||
<PlaybackControls />
|
||||
<main>
|
||||
{this.props.children}
|
||||
</main>
|
||||
|
||||
<div className="body">
|
||||
<Sidebar />
|
||||
<PlaybackControls />
|
||||
<main>
|
||||
{this.props.children}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<ContextMenu />
|
||||
<Dragger />
|
||||
<Modal />
|
||||
|
||||
@ -9,27 +9,26 @@ export default class CreatePlaylistModal extends React.Component{
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state = {
|
||||
submit_enabled: false,
|
||||
name: '',
|
||||
description: '',
|
||||
scheme: 'spotify',
|
||||
is_public: true
|
||||
is_public: true,
|
||||
is_collaborative: false
|
||||
}
|
||||
}
|
||||
|
||||
createPlaylist(e){
|
||||
e.preventDefault();
|
||||
this.props.uiActions.createPlaylist( this.state.scheme, this.state.name, this.state.is_public )
|
||||
this.props.uiActions.closeModal()
|
||||
return false;
|
||||
}
|
||||
e.preventDefault();
|
||||
|
||||
setPlaylistName(name){
|
||||
var submit_enabled = false
|
||||
if( name && name != '' ) submit_enabled = true
|
||||
this.setState({
|
||||
name: name,
|
||||
submit_enabled: submit_enabled
|
||||
})
|
||||
if (!this.state.name || this.state.name == ''){
|
||||
this.setState({error: 'Name is required'})
|
||||
return false
|
||||
} else {
|
||||
this.props.uiActions.createPlaylist( this.state.scheme, this.state.name, this.state.description, this.state.is_public, this.state.is_collaborative )
|
||||
this.props.uiActions.closeModal()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
render(){
|
||||
@ -37,14 +36,25 @@ export default class CreatePlaylistModal extends React.Component{
|
||||
<div>
|
||||
<h1>Create playlist</h1>
|
||||
<form onSubmit={(e) => this.createPlaylist(e)}>
|
||||
<div className="field">
|
||||
|
||||
<div className="field text">
|
||||
<span className="label">Name</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Playlist name"
|
||||
onChange={ e => this.setPlaylistName( e.target.value )}
|
||||
onChange={ e => this.setState({ name: e.target.value })}
|
||||
value={ this.state.name } />
|
||||
</div>
|
||||
|
||||
<div className="field text">
|
||||
<span className="label">Description</span>
|
||||
<input
|
||||
type="text"
|
||||
onChange={ e => this.setState({ description: e.target.value })}
|
||||
|
||||
value={ this.state.description } />
|
||||
</div>
|
||||
<div className="field radio white">
|
||||
<span className="label">Provider</span>
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
@ -61,10 +71,11 @@ export default class CreatePlaylistModal extends React.Component{
|
||||
value="m3u"
|
||||
checked={ this.state.scheme == 'm3u' }
|
||||
onChange={ e => this.setState({ scheme: e.target.value })} />
|
||||
<span className="label">Local (m3u)</span>
|
||||
<span className="label">Mopidy</span>
|
||||
</label>
|
||||
</div>
|
||||
<div className="field checkbox white">
|
||||
<span className="label">Options</span>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
@ -73,9 +84,17 @@ export default class CreatePlaylistModal extends React.Component{
|
||||
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>
|
||||
<div className="actions centered-text">
|
||||
<button type="submit" className="primary wide" disabled={!this.state.submit_enabled}>Save</button>
|
||||
<button type="submit" className="primary wide">Create</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -12,7 +12,8 @@ export default class EditPlaylistModal extends React.Component{
|
||||
error: null,
|
||||
name: this.props.data.name,
|
||||
description: (this.props.data.description ? this.props.data.description : ''),
|
||||
is_public: this.props.data.is_public
|
||||
is_public: this.props.data.is_public,
|
||||
is_collaborative: this.props.data.is_collaborative
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +24,7 @@ export default class EditPlaylistModal extends React.Component{
|
||||
this.setState({error: 'Name is required'})
|
||||
return false
|
||||
} else {
|
||||
this.props.uiActions.savePlaylist(this.props.data.uri, this.state.name, this.state.is_public, this.state.description)
|
||||
this.props.uiActions.savePlaylist(this.props.data.uri, this.state.name, this.state.description, this.state.is_public, this.state.is_collaborative)
|
||||
this.props.uiActions.closeModal()
|
||||
return false
|
||||
}
|
||||
@ -35,21 +36,22 @@ export default class EditPlaylistModal extends React.Component{
|
||||
case 'spotify':
|
||||
return (
|
||||
<div>
|
||||
<div className="field">
|
||||
<div className="field text">
|
||||
<span className="label">Name</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
onChange={ e => this.setState({ name: e.target.value })}
|
||||
value={ this.state.name } />
|
||||
</div>
|
||||
<div className="field">
|
||||
<div className="field text">
|
||||
<span className="label">Description</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Description"
|
||||
onChange={ e => this.setState({ description: e.target.value })}
|
||||
value={ this.state.description } />
|
||||
</div>
|
||||
<div className="field checkbox white">
|
||||
<span className="label">Options</span>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
@ -58,6 +60,14 @@ export default class EditPlaylistModal extends React.Component{
|
||||
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>
|
||||
</div>
|
||||
)
|
||||
@ -67,9 +77,9 @@ export default class EditPlaylistModal extends React.Component{
|
||||
return (
|
||||
<div>
|
||||
<div className="field">
|
||||
<span className="label">Name</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
onChange={ e => this.setState({ name: e.target.value })}
|
||||
value={ this.state.name } />
|
||||
</div>
|
||||
|
||||
@ -1072,10 +1072,17 @@ export function toggleAlbumInLibrary( uri, method ){
|
||||
* ======================================================================================
|
||||
**/
|
||||
|
||||
export function createPlaylist( name, is_public ){
|
||||
export function createPlaylist( name, description, is_public, is_collaborative ){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
sendRequest( dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/', 'POST', { name: name, public: is_public } )
|
||||
var data = {
|
||||
name: name,
|
||||
description: description,
|
||||
public: is_public,
|
||||
collaborative: is_collaborative
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/', 'POST', data)
|
||||
.then( response => {
|
||||
|
||||
dispatch({
|
||||
@ -1102,13 +1109,14 @@ export function createPlaylist( name, is_public ){
|
||||
}
|
||||
}
|
||||
|
||||
export function savePlaylist(uri, name, is_public, description){
|
||||
export function savePlaylist(uri, name, description, is_public, is_collaborative){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
var data = {
|
||||
name: name,
|
||||
name: name,
|
||||
description: description,
|
||||
public: is_public,
|
||||
description: description
|
||||
collaborative: is_collaborative
|
||||
}
|
||||
|
||||
sendRequest( dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri), 'PUT', data)
|
||||
@ -1119,6 +1127,7 @@ export function savePlaylist(uri, name, is_public, description){
|
||||
playlist: {
|
||||
name: name,
|
||||
public: is_public,
|
||||
collaborative: is_collaborative,
|
||||
description: description
|
||||
}
|
||||
})
|
||||
|
||||
@ -23,7 +23,7 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
|
||||
return
|
||||
}
|
||||
store.dispatch( spotifyActions.createPlaylist( action.name, action.is_private ))
|
||||
store.dispatch( spotifyActions.createPlaylist( action.name, action.description, action.is_private, action.is_collaborative ))
|
||||
break
|
||||
|
||||
case 'SPOTIFY_REMOVE_PLAYLIST_TRACKS':
|
||||
@ -72,7 +72,7 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
|
||||
return
|
||||
}
|
||||
store.dispatch( spotifyActions.savePlaylist( action.key, action.name, action.is_public, action.description ))
|
||||
store.dispatch( spotifyActions.savePlaylist( action.key, action.name, action.description, action.is_public, action.is_collaborative ))
|
||||
break
|
||||
|
||||
// when radio returns
|
||||
|
||||
@ -130,7 +130,7 @@ export function reorderPlaylistTracks( uri, indexes, insert_before, snapshot_id
|
||||
}
|
||||
}
|
||||
|
||||
export function savePlaylist(uri, name, is_public = false, description = ''){
|
||||
export function savePlaylist(uri, name, description = '', is_public = false, is_collaborative = false){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
|
||||
case 'spotify':
|
||||
@ -138,8 +138,9 @@ export function savePlaylist(uri, name, is_public = false, description = ''){
|
||||
type: 'SPOTIFY_SAVE_PLAYLIST',
|
||||
key: uri,
|
||||
name: name,
|
||||
description: (description == '' ? null : description),
|
||||
is_public: is_public,
|
||||
description: (description == '' ? null : description)
|
||||
is_collaborative: is_collaborative
|
||||
}
|
||||
|
||||
case 'm3u':
|
||||
@ -152,14 +153,16 @@ export function savePlaylist(uri, name, is_public = false, description = ''){
|
||||
return false
|
||||
}
|
||||
|
||||
export function createPlaylist( scheme, name, is_public = false ){
|
||||
export function createPlaylist(scheme, name, description = '', is_public = false, is_collaborative = false){
|
||||
switch( scheme ){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_CREATE_PLAYLIST',
|
||||
name: name,
|
||||
is_public: is_public
|
||||
description: (description == '' ? null : description),
|
||||
is_public: is_public,
|
||||
is_collaborative: is_collaborative
|
||||
}
|
||||
|
||||
case 'm3u':
|
||||
|
||||
Reference in New Issue
Block a user