enables class properties, updates eslint

This commit is contained in:
James
2018-12-06 12:32:54 -08:00
parent 2a741501bc
commit 33534976aa
5 changed files with 180 additions and 63 deletions

View File

@@ -7,6 +7,7 @@ table {
@extend %uppercase-label;
font-weight: normal;
text-align: left;
color: $gray;
}
td, th {
@@ -15,7 +16,6 @@ table {
tbody {
@extend %inputShadow;
border-radius: $radius-sm;
}
tr:nth-child(even) {

View File

@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Filter, Table } from 'payload/components'
class SearchableTable extends Component {
@@ -24,23 +25,31 @@ class SearchableTable extends Component {
structureRows = () => {
if (this.props.data) {
return this.props.data.map(row => {
if (columns) {
const columnKeys = this.state.columns.map(col => col.key);
return getPropSubset(columnKeys, row);
}
return {};
const formattedRow = {...row};
// Link the first column
formattedRow[this.state.columns[0].key] = <Link to={'/'}>{row[this.state.columns[0].key]}</Link>
return formattedRow;
})
}
return [];
}
componentDidUpdate(prevProps) {
if (prevProps.data !== this.props.data) {
this.setState({
rows: this.structureRows(this.props.data)
})
}
}
render() {
return (
<React.Fragment>
<Filter />
<Table rows={this.props.data} columns={this.state.columns} />
<Table rows={this.state.rows} columns={this.state.columns} />
</React.Fragment>
)
}