2017-04-10 16:28:30 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* TableRow
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-04-11 17:35:40 +02:00
|
|
|
import { Link } from 'react-router';
|
2017-04-11 11:34:59 +02:00
|
|
|
|
2017-04-10 16:28:30 +02:00
|
|
|
import styles from './styles.scss';
|
|
|
|
|
|
|
|
class TableRow extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
2017-04-11 15:38:15 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.goEditPage = this.goEditPage.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
goEditPage() {
|
|
|
|
this.context.router.push(this.props.destination);
|
|
|
|
}
|
|
|
|
|
2017-04-10 16:28:30 +02:00
|
|
|
render() {
|
2017-04-11 11:34:59 +02:00
|
|
|
const cells = this.props.headers.map((header, i) => (<td key={i} className={styles.tableRowCell}>{this.props.record[header.name]}</td>));
|
2017-04-10 16:28:30 +02:00
|
|
|
|
|
|
|
return (
|
2017-04-11 15:38:15 +02:00
|
|
|
<tr className={styles.tableRow} onClick={() => this.goEditPage(this.props.destination)}>
|
2017-04-10 16:28:30 +02:00
|
|
|
{cells}
|
|
|
|
<td className={styles.actions}>
|
|
|
|
<Link to={this.props.destination}>
|
|
|
|
<i className="ion ion-edit"></i>
|
|
|
|
</Link>
|
|
|
|
<Link to={this.props.destination}>
|
|
|
|
<i className="ion ion-close-round"></i>
|
|
|
|
</Link>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-11 15:38:15 +02:00
|
|
|
TableRow.contextTypes = {
|
|
|
|
router: React.PropTypes.object.isRequired
|
|
|
|
};
|
|
|
|
|
2017-04-10 16:28:30 +02:00
|
|
|
TableRow.propTypes = {
|
|
|
|
headers: React.PropTypes.array,
|
|
|
|
record: React.PropTypes.object,
|
|
|
|
destination: React.PropTypes.string,
|
2017-04-11 15:38:15 +02:00
|
|
|
history: React.PropTypes.object,
|
2017-04-10 16:28:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default TableRow;
|