Sort dropdown to show current sort order
This commit is contained in:
@ -40,13 +40,19 @@ export default class DropdownField extends React.Component{
|
||||
}
|
||||
|
||||
render(){
|
||||
if( !this.props.options ) return null
|
||||
if (!this.props.options) return null
|
||||
|
||||
var classname = 'dropdown-field'
|
||||
if( this.state.expanded ) classname += ' expanded'
|
||||
if (this.state.expanded) classname += ' expanded'
|
||||
|
||||
var current_value = this.props.options[0].value
|
||||
if( this.props.value ) current_value = this.props.value
|
||||
if (this.props.value) current_value = this.props.value
|
||||
|
||||
var icon = <FontAwesome name="check" />
|
||||
if (typeof(this.props.reverse) !== 'undefined'){
|
||||
if (this.props.reverse) icon = <FontAwesome className="reverse" name="caret-up" />
|
||||
else icon = <FontAwesome className="reverse" name="caret-down" />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classname} data-key={this.props.name.replace(' ','_').toLowerCase()}>
|
||||
@ -59,8 +65,8 @@ export default class DropdownField extends React.Component{
|
||||
this.props.options.map( option => {
|
||||
return (
|
||||
<div className="option" key={ option.value } onClick={ e => this.handleChange(option.value) }>
|
||||
{ option.value == current_value ? <FontAwesome name="check" /> : null }
|
||||
{ option.label }
|
||||
{option.value == current_value ? icon : null}
|
||||
{option.label}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
@ -45,14 +45,19 @@ class LibraryArtists extends React.Component{
|
||||
if( this.props.view == 'list' ){
|
||||
var columns = [
|
||||
{
|
||||
width: 60,
|
||||
label: 'Name',
|
||||
width: 70,
|
||||
name: 'name'
|
||||
},
|
||||
{
|
||||
width: 10,
|
||||
label: 'Followers',
|
||||
width: 15,
|
||||
name: 'followers.total'
|
||||
},
|
||||
{
|
||||
label: 'Popularity',
|
||||
width: 15,
|
||||
name: 'popularity'
|
||||
}
|
||||
]
|
||||
return (
|
||||
@ -87,30 +92,34 @@ class LibraryArtists extends React.Component{
|
||||
|
||||
var view_options = [
|
||||
{
|
||||
value: 'thumbnails',
|
||||
label: 'Thumbnails'
|
||||
label: 'Thumbnails',
|
||||
value: 'thumbnails'
|
||||
},
|
||||
{
|
||||
value: 'list',
|
||||
label: 'List'
|
||||
label: 'List',
|
||||
value: 'list'
|
||||
}
|
||||
]
|
||||
|
||||
var sort_options = [
|
||||
{
|
||||
value: 'name',
|
||||
label: 'Name'
|
||||
label: 'Name',
|
||||
value: 'name'
|
||||
},
|
||||
{
|
||||
value: 'followers.total',
|
||||
label: 'Followers'
|
||||
label: 'Followers',
|
||||
value: 'followers.total'
|
||||
},
|
||||
{
|
||||
label: 'Popularity',
|
||||
value: 'popularity'
|
||||
}
|
||||
]
|
||||
|
||||
var actions = (
|
||||
<span>
|
||||
<DropdownField icon="sort" name="Sort" value={ this.props.sort } options={ sort_options } handleChange={ value => this.setSort(value) } />
|
||||
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.set({ library_artists_view: value }) } />
|
||||
<DropdownField icon="sort" name="Sort" value={ this.props.sort } options={sort_options} reverse={this.props.sort_reverse} handleChange={ value => this.setSort(value) } />
|
||||
<DropdownField icon="eye" name="View" value={ this.props.view } options={view_options} handleChange={ value => this.props.uiActions.set({ library_artists_view: value }) } />
|
||||
</span>
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user