2016-11-01 19:27:59 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { Link } from 'react-router'
|
|
|
|
|
|
|
|
|
|
export default class List extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderHeader(){
|
|
|
|
|
if( !this.props.columns ) return null
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="list-item header cf">
|
|
|
|
|
{
|
|
|
|
|
this.props.columns.map( (col, col_index) => {
|
|
|
|
|
return <div className={'col w'+col.width} key={col_index}>{ col.name }</div>
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
return (
|
|
|
|
|
<div className="list">
|
|
|
|
|
{ this.renderHeader() }
|
|
|
|
|
{
|
|
|
|
|
this.props.rows.map( (row, row_index) => {
|
|
|
|
|
return (
|
|
|
|
|
<Link to={ this.props.link_prefix + encodeURIComponent(row.uri)} className="list-item cf" key={row_index}>
|
|
|
|
|
{
|
|
|
|
|
this.props.columns.map( (col, col_index) => {
|
2016-11-02 21:23:35 +13:00
|
|
|
return (
|
|
|
|
|
<div className={'col w'+col.width} key={col_index}>
|
|
|
|
|
{ row[col.name] ? row[col.name] : <span>-</span> }
|
|
|
|
|
</div>
|
|
|
|
|
)
|
2016-11-01 19:27:59 +13:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|