Partial sorting

This commit is contained in:
James Barnsley
2016-12-09 18:47:10 +13:00
parent f89189c715
commit 26b069faa7
7 changed files with 69 additions and 17 deletions

View File

@ -109,7 +109,7 @@ class LibraryAlbums extends React.Component{
]
var actions = (
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.setView({ library_albums_view: value }) } />
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.set({ library_albums_view: value }) } />
)
return (

View File

@ -74,7 +74,7 @@ class LibraryArtists extends React.Component{
]
var actions = (
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.setView({ library_artists_view: value }) } />
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.set({ library_artists_view: value }) } />
)
return (

View File

@ -10,6 +10,7 @@ import List from '../../components/List'
import DropdownField from '../../components/DropdownField'
import Header from '../../components/Header'
import * as helpers from '../../helpers'
import * as uiActions from '../../services/ui/actions'
import * as mopidyActions from '../../services/mopidy/actions'
import * as spotifyActions from '../../services/spotify/actions'
@ -23,6 +24,11 @@ class LibraryPlaylists extends React.Component{
renderView(){
if( !this.props.playlists ) return null
var playlists = this.props.playlists
if( this.props.sort ){
playlists = helpers.sortItems(playlists, this.props.sort)
}
if( this.props.view == 'list' ){
var columns = [
{
@ -48,7 +54,7 @@ class LibraryPlaylists extends React.Component{
]
return (
<section className="list-wrapper">
<List rows={this.props.playlists} columns={columns} link_prefix="/playlist/" show_source_icon={true} />
<List rows={playlists} columns={columns} link_prefix="/playlist/" show_source_icon={true} />
</section>
)
}else{
@ -73,9 +79,25 @@ class LibraryPlaylists extends React.Component{
}
]
var sort_options = [
{
value: 'name',
label: 'Name'
},
{
value: 'can_edit',
label: 'Editable'
},
{
value: 'tracks.total',
label: 'Tracks'
}
]
var actions = (
<div>
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.setView({ library_playlists_view: value }) } />
<DropdownField icon="sort" name="Sort" value={ this.props.sort } options={ sort_options } handleChange={ value => this.props.uiActions.set({ library_playlists_sort: value }) } />
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.set({ library_playlists_view: value }) } />
<button onClick={ () => this.props.uiActions.openModal('create_playlist', {} ) }>
<FontAwesome name="plus" />&nbsp;
New
@ -102,6 +124,7 @@ class LibraryPlaylists extends React.Component{
const mapStateToProps = (state, ownProps) => {
return {
view: state.ui.library_playlists_view,
sort: state.ui.library_playlists_sort,
playlists: state.ui.playlists
}
}