2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
2016-11-21 07:59:52 +13:00
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-11-14 17:32:36 +13:00
|
|
|
import Icon from '../Icon'
|
|
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
|
2016-11-19 13:06:08 +13:00
|
|
|
export default class AddToPlaylistModal extends React.Component{
|
2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playlistSelected( playlist_uri ){
|
2016-11-19 13:06:08 +13:00
|
|
|
this.props.uiActions.addTracksToPlaylist( playlist_uri, this.props.tracks_uris )
|
2016-11-14 17:32:36 +13:00
|
|
|
this.props.uiActions.closeModal()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
if( !this.props.playlists ) return <div className="empty">No editable playlists</div>
|
|
|
|
|
var playlists = []
|
2017-01-16 21:49:04 +13:00
|
|
|
for (var uri in this.props.playlists){
|
|
|
|
|
if( this.props.playlists[uri].can_edit ) playlists.push( this.props.playlists[uri] )
|
2016-11-14 17:32:36 +13:00
|
|
|
}
|
|
|
|
|
|
2017-01-16 21:49:04 +13:00
|
|
|
playlists = helpers.sortItems(playlists, 'name')
|
|
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
return (
|
2016-11-21 07:59:52 +13:00
|
|
|
<div>
|
|
|
|
|
<h4>Add to playlist</h4>
|
2016-12-12 09:07:47 +13:00
|
|
|
<div className="list playlists">
|
2016-11-21 07:59:52 +13:00
|
|
|
{
|
|
|
|
|
playlists.map( playlist => {
|
|
|
|
|
return (
|
2017-01-30 16:59:37 +13:00
|
|
|
<div className="list-item small" key={playlist.uri} onClick={ () => this.playlistSelected(playlist.uri) }>
|
2016-11-21 07:59:52 +13:00
|
|
|
<FontAwesome className="source" name={helpers.sourceIcon(playlist.uri)} />
|
|
|
|
|
|
|
|
|
|
<span className="name">{ playlist.name }</span>
|
2017-01-18 16:52:55 +13:00
|
|
|
{ playlist.tracks_total ? <span className="grey-text"> { playlist.tracks_total } tracks</span> : null }
|
2016-11-21 07:59:52 +13:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
2016-11-14 17:32:36 +13:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|