1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00
onion/js/components/ascribe_table/table_item_selectable.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
2015-05-26 16:48:48 +02:00
import React from 'react';
import classNames from 'classnames';
import { ColumnModel } from './models/table_models';
2015-05-26 16:48:48 +02:00
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(ColumnModel)),
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,
selectItem: React.PropTypes.func
2015-05-26 16:48:48 +02:00
},
2015-05-26 19:50:18 +02:00
selectItem() {
2015-07-08 17:35:30 +02:00
this.props.selectItem(this.props.parentId, this.props.columnContent.id);
2015-05-26 19:50:18 +02:00
},
2015-05-26 16:48:48 +02:00
render() {
let tableItemClasses = classNames({
'ascribe-table-item-selected': this.props.columnContent.selected
});
2015-06-01 14:10:11 +02:00
return (
<TableItem
2015-06-01 14:10:11 +02:00
className={tableItemClasses + ' ' + this.props.className}
columnList={this.props.columnList}
columnContent={this.props.columnContent}
onClick={this.selectItem} />
2015-06-01 14:10:11 +02:00
);
2015-05-26 16:48:48 +02:00
}
});
export default TableItemSelectable;