1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/components/ascribe_table/table.js

49 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

'use strict';
import React from 'react';
2015-05-20 14:48:57 +02:00
import TableHeader from './table_header';
import { ColumnModel } from './models/table_models';
2015-05-20 16:44:45 +02:00
let Table = React.createClass({
2015-05-20 14:48:57 +02:00
propTypes: {
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)),
changeOrder: React.PropTypes.func,
orderBy: React.PropTypes.string,
orderAsc: React.PropTypes.bool,
className: React.PropTypes.string,
2015-06-05 11:32:10 +02:00
children: React.PropTypes.array,
itemList: React.PropTypes.array
2015-05-20 14:48:57 +02:00
},
renderChildren() {
return React.Children.map(this.props.children, (child, i) => {
return React.cloneElement(child, {
2015-05-26 13:14:35 +02:00
columnList: this.props.columnList,
columnContent: this.props.itemList[i],
key: i
});
});
},
2015-05-22 18:43:15 +02:00
render() {
return (
2015-06-04 17:21:38 +02:00
<table className={'table ' + this.props.className}>
<TableHeader
columnList={this.props.columnList}
itemList={this.props.itemList}
changeOrder={this.props.changeOrder}
orderAsc={this.props.orderAsc}
orderBy={this.props.orderBy} />
2015-06-04 17:21:38 +02:00
<tbody>
{this.renderChildren()}
2015-06-04 17:21:38 +02:00
</tbody>
</table>
);
}
});
2015-05-20 12:00:16 +02:00
export default Table;