2016-10-18 21:57:29 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
2017-01-27 13:24:36 +13:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { createStore, bindActionCreators } from 'redux'
|
|
|
|
|
import { hashHistory } from 'react-router'
|
|
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-10-18 21:57:29 +13:00
|
|
|
|
2017-03-27 08:29:18 +13:00
|
|
|
import * as helpers from '../helpers'
|
2017-01-27 13:24:36 +13:00
|
|
|
import * as uiActions from '../services/ui/actions'
|
2017-08-09 08:52:49 +12:00
|
|
|
import GridItem from './GridItem'
|
2017-01-27 13:24:36 +13:00
|
|
|
|
|
|
|
|
class AlbumGrid extends React.Component{
|
2016-10-18 21:57:29 +13:00
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
constructor(props){
|
2017-08-09 08:52:49 +12:00
|
|
|
super(props)
|
2017-01-27 13:24:36 +13:00
|
|
|
}
|
|
|
|
|
|
2017-01-29 11:56:58 +13:00
|
|
|
handleContextMenu(e,item){
|
2017-01-27 13:24:36 +13:00
|
|
|
e.preventDefault()
|
2017-01-29 11:56:58 +13:00
|
|
|
var data = {
|
2017-01-29 16:34:17 +13:00
|
|
|
e: e,
|
|
|
|
|
context: 'album',
|
2017-01-29 11:56:58 +13:00
|
|
|
uris: [item.uri],
|
2017-02-28 16:13:27 +13:00
|
|
|
items: [item]
|
2017-01-29 11:56:58 +13:00
|
|
|
}
|
2017-01-29 16:34:17 +13:00
|
|
|
this.props.uiActions.showContextMenu(data)
|
2017-01-27 13:24:36 +13:00
|
|
|
}
|
|
|
|
|
|
2016-10-18 21:57:29 +13:00
|
|
|
render(){
|
2017-10-10 13:05:28 +13:00
|
|
|
if (this.props.albums){
|
2016-10-26 08:51:28 +13:00
|
|
|
var className = "grid album-grid"
|
2017-09-03 16:10:32 +12:00
|
|
|
if (this.props.className) className += ' '+this.props.className
|
|
|
|
|
if (this.props.single_row) className += ' single-row'
|
|
|
|
|
|
2016-10-18 21:57:29 +13:00
|
|
|
return (
|
2016-10-26 08:51:28 +13:00
|
|
|
<div className={className}>
|
2016-10-18 21:57:29 +13:00
|
|
|
{
|
2017-08-09 08:52:49 +12:00
|
|
|
this.props.albums.map(album => {
|
|
|
|
|
return (
|
|
|
|
|
<GridItem
|
|
|
|
|
key={album.uri}
|
|
|
|
|
type="album"
|
|
|
|
|
item={album}
|
|
|
|
|
onClick={e => {hashHistory.push(global.baseURL+'album/'+album.uri)}}
|
2017-08-10 08:02:10 +12:00
|
|
|
onLoad={() => this.handleLoad(album.uri)}
|
2017-08-09 08:52:49 +12:00
|
|
|
onContextMenu={e => this.handleContextMenu(e,album)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2016-10-18 21:57:29 +13:00
|
|
|
)
|
|
|
|
|
}
|
2016-10-26 08:51:28 +13:00
|
|
|
</div>
|
2016-10-18 21:57:29 +13:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 13:24:36 +13:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AlbumGrid)
|
|
|
|
|
|