2015-05-26 16:48:48 +02:00
|
|
|
import React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
import TableColumnContentModel from '../../models/table_column_content_model';
|
|
|
|
|
|
|
|
import TableItem from './table_item';
|
|
|
|
|
2015-05-27 08:24:13 +02:00
|
|
|
// This component is implemented as recommended here: http://stackoverflow.com/a/25723635/1263876
|
2015-05-26 16:48:48 +02:00
|
|
|
let TableItemSelectable = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)),
|
2015-05-27 09:05:39 +02:00
|
|
|
columnContent: React.PropTypes.object,
|
2015-05-27 09:56:26 +02:00
|
|
|
parentId: React.PropTypes.number,
|
|
|
|
className: React.PropTypes.string
|
2015-05-26 16:48:48 +02:00
|
|
|
},
|
|
|
|
|
2015-05-26 19:50:18 +02:00
|
|
|
selectItem() {
|
|
|
|
this.props.selectItem(this.props.parentId, this.props.columnContent.edition_number);
|
|
|
|
},
|
|
|
|
|
2015-05-26 16:48:48 +02:00
|
|
|
render() {
|
|
|
|
let tableItemClasses = classNames({
|
|
|
|
'ascribe-table-item-selected': this.props.columnContent.selected
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2015-05-27 08:24:13 +02:00
|
|
|
<TableItem
|
2015-05-27 09:56:26 +02:00
|
|
|
classNames={tableItemClasses + ' ' + this.props.className}
|
2015-05-26 16:48:48 +02:00
|
|
|
columnList={this.props.columnList}
|
|
|
|
columnContent={this.props.columnContent}
|
2015-05-26 19:50:18 +02:00
|
|
|
onClick={this.selectItem}>
|
2015-05-26 16:48:48 +02:00
|
|
|
</TableItem>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default TableItemSelectable;
|