|
@@ -4,6 +4,7 @@ import Paper from 'material-ui/Paper'
|
|
|
import Button from 'material-ui/Button'
|
|
|
import Table, { TableHead, TableBody, TableRow, TableCell} from 'material-ui/Table'
|
|
|
import Checkbox from 'material-ui/Checkbox'
|
|
|
+import { difference } from 'lodash'
|
|
|
|
|
|
const styles = theme => ({
|
|
|
root: {
|
|
@@ -23,10 +24,37 @@ const styles = theme => ({
|
|
|
|
|
|
class ContainersTable extends Component {
|
|
|
|
|
|
- render() {
|
|
|
- const { classes, theme, columns, rows } = this.props
|
|
|
+ constructor(props) {
|
|
|
+ super(props)
|
|
|
+
|
|
|
+ this.state = {
|
|
|
+ selectedRows: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+ */
|
|
|
+ selectAll(e) {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+ */
|
|
|
+ selectRow(e, id) {
|
|
|
+ this.setState({
|
|
|
+ selectedRows: difference([id], this.state.selectedRows)
|
|
|
+ })
|
|
|
|
|
|
- console.log(theme)
|
|
|
+ console.log(this.state.selectedRows)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+ */
|
|
|
+ render() {
|
|
|
+ const { classes, columns, rows } = this.props
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
@@ -38,7 +66,7 @@ class ContainersTable extends Component {
|
|
|
<TableHead>
|
|
|
<TableRow>
|
|
|
<TableCell>
|
|
|
- {}
|
|
|
+ { <Checkbox color='primary' onClick={(e) => this.selectAll(e)} /> }
|
|
|
</TableCell>
|
|
|
{columns.map(column =>
|
|
|
<TableCell>{column.title}</TableCell>
|
|
@@ -49,7 +77,7 @@ class ContainersTable extends Component {
|
|
|
{rows.map(item =>
|
|
|
<TableRow key={item.id} className={classes.tableRow}>
|
|
|
<TableCell>
|
|
|
- <Checkbox color='primary' />
|
|
|
+ <Checkbox color='primary' onClick={(e) => this.selectRow(e, item.id)} />
|
|
|
</TableCell>
|
|
|
{columns.map(column =>
|
|
|
<TableCell>{item[column.key]}</TableCell>
|