2015-05-20 11:16:42 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
2015-05-21 15:14:05 +02:00
|
|
|
import TableColumnMixin from '../../mixins/table_column_mixin';
|
2015-05-20 14:48:57 +02:00
|
|
|
|
2015-05-22 16:51:08 +02:00
|
|
|
import TableColumnContentModel from '../../models/table_column_content_model';
|
2015-05-21 16:02:42 +02:00
|
|
|
|
2015-05-20 16:44:45 +02:00
|
|
|
|
2015-05-20 11:16:42 +02:00
|
|
|
let TableItem = React.createClass({
|
2015-05-20 14:48:57 +02:00
|
|
|
mixins: [TableColumnMixin],
|
2015-05-20 15:44:15 +02:00
|
|
|
|
2015-05-20 14:48:57 +02:00
|
|
|
propTypes: {
|
2015-05-22 16:51:08 +02:00
|
|
|
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)),
|
2015-05-26 16:48:48 +02:00
|
|
|
columnContent: React.PropTypes.object,
|
|
|
|
onClick: React.PropTypes.func, // See: https://facebook.github.io/react/tips/expose-component-functions.html
|
|
|
|
classNames: React.PropTypes.string
|
2015-05-20 14:48:57 +02:00
|
|
|
},
|
2015-05-20 12:09:35 +02:00
|
|
|
|
2015-05-21 16:02:42 +02:00
|
|
|
render() {
|
2015-05-20 15:22:29 +02:00
|
|
|
let calcColumnElementContent = () => {
|
2015-05-21 16:02:42 +02:00
|
|
|
return this.props.columnList.map((column, i) => {
|
2015-05-20 15:44:15 +02:00
|
|
|
|
2015-05-21 16:02:42 +02:00
|
|
|
let TypeElement = column.displayType;
|
2015-05-26 14:57:32 +02:00
|
|
|
let columnClass = this.calcColumnClasses(this.props.columnList, i, 12);
|
2015-05-20 15:44:15 +02:00
|
|
|
|
|
|
|
return (
|
2015-05-20 17:32:06 +02:00
|
|
|
<div className={columnClass + ' ascribe-table-item-column'} key={i}>
|
2015-05-21 16:02:42 +02:00
|
|
|
<TypeElement content={this.props.columnContent[column.columnName]} width="50" />
|
2015-05-20 15:44:15 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2015-05-20 15:22:29 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-05-20 11:16:42 +02:00
|
|
|
return (
|
2015-05-26 16:48:48 +02:00
|
|
|
<div
|
|
|
|
className={this.props.classNames + ' col-xs-12 col-sm-12 col-md-12 col-lg-12 ascribe-table-item'}
|
|
|
|
onClick={this.props.onClick}>
|
2015-05-20 12:09:35 +02:00
|
|
|
<div className="row">
|
2015-05-20 15:22:29 +02:00
|
|
|
{calcColumnElementContent()}
|
2015-05-20 12:09:35 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-05-20 11:16:42 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-05-20 16:44:45 +02:00
|
|
|
export default TableItem;
|