1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/components/ascribe_table/table.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
import React from 'react';
import ReactAddons from 'react/addons';
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() {
var that = this;
2015-05-26 13:14:35 +02:00
return ReactAddons.Children.map(this.props.children, (child, i) => {
return ReactAddons.addons.cloneWithProps(child, {
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;