Skip to content

Commit

Permalink
eslint problem resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrn committed Oct 17, 2018
1 parent d91f819 commit ecddb07
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 46 deletions.
13 changes: 6 additions & 7 deletions src/m-table-body-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import MTableCell from './m-table-cell';
import MTableActions from './m-table-actions'
import MTableActions from './m-table-actions';
import { Checkbox, TableRow, TableCell } from '@material-ui/core';
/* eslint-enable no-unused-vars */

export default class MTableBodyRow extends React.Component {

render() {
return (
<TableRow selected={this.props.index % 2 === 0}>
{this.props.options.selection
? <TableCell padding="checkbox" key="key-selection-column">
? <TableCell padding="checkbox" key="key-selection-column">
<Checkbox
checked={this.props.data.tableData.checked === true}
value={`${this.props.data.tableData.id}`}
onChange={this.props.onRowSelected}
/>
</TableCell>
: (this.props.actions && this.props.actions.filter(a => (!a.isFreeAction)).length > 0) &&
: (this.props.actions && this.props.actions.filter(a => (!a.isFreeAction)).length > 0) &&
<TableCell style={{paddingTop: 0, paddingBottom: 0}} key="key-actions-column">
<div style={{display: 'flex'}}>
<MTableActions data={this.props.data} actions={this.props.actions.filter(a => { return !a.isFreeAction })}/>
Expand All @@ -37,7 +36,7 @@ export default class MTableBodyRow extends React.Component {

MTableBodyRow.defaultProps = {
actions: [],
index: 0,
index: 0,
data: {},
options: {}
};
Expand All @@ -48,5 +47,5 @@ MTableBodyRow.propTypes = {
data: PropTypes.object.isRequired,
options: PropTypes.object.isRequired,
onRowSelected: PropTypes.func,
getFieldValue: PropTypes.func.isRequired
};
getFieldValue: PropTypes.func.isRequired
};
8 changes: 4 additions & 4 deletions src/m-table-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default class MTableBody extends React.Component {
{
renderData.map((data, index) => {
return (
<MTableBodyRow
data={data}
<MTableBodyRow
data={data}
index={index}
key={index}
options={this.props.options}
Expand All @@ -41,7 +41,7 @@ export default class MTableBody extends React.Component {
);
})
}
{[...Array(emptyRowCount)].map((r, index) => <TableRow style={{height: 49}} key={"empty-" + index} />)}
{[...Array(emptyRowCount)].map((r, index) => <TableRow style={{height: 49}} key={'empty-' + index} />)}
{emptyRowCount > 0 && <div style={{height: 1}}/>}
</TableBody>
);
Expand All @@ -63,5 +63,5 @@ MTableBody.propTypes = {
onRowSelected: PropTypes.func,
options: PropTypes.object.isRequired,
pageSize: PropTypes.number,
renderData: PropTypes.array,
renderData: PropTypes.array
};
5 changes: 2 additions & 3 deletions src/m-table-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ export default class MTableCell extends React.Component {

render() {
let cellStyle = {};
if(typeof this.props.columnDef.cellStyle === "function" ) {
if (typeof this.props.columnDef.cellStyle === 'function') {
cellStyle = Object.assign(cellStyle, this.props.columnDef.cellStyle(this.props.value));
}
else {
} else {
cellStyle = Object.assign(cellStyle, this.props.columnDef.cellStyle);
}

Expand Down
6 changes: 3 additions & 3 deletions src/m-table-filter-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import {
TableCell, TableRow, TextField,
FormControl, Select, Input,
MenuProps, MenuItem, Checkbox,
FormControl, Select, Input,
MenuProps, MenuItem, Checkbox,
ListItemText, InputAdornment, Icon
} from '@material-ui/core';
/* eslint-enable no-unused-vars */
Expand Down Expand Up @@ -89,7 +89,7 @@ class MTableFilterRow extends React.Component {

MTableFilterRow.defaultProps = {
emptyCell: false,
columns: [],
columns: []
};

MTableFilterRow.propTypes = {
Expand Down
23 changes: 11 additions & 12 deletions src/m-table-header.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import * as React from 'react';
import PropTypes from 'prop-types';
import {
TableHead, TableRow, TableCell,
import {
TableHead, TableRow, TableCell,
TableSortLabel, Checkbox, withStyles
} from '@material-ui/core';
/* eslint-enable no-unused-vars */
Expand All @@ -14,19 +14,19 @@ class MTableHeader extends React.Component {
<TableRow>
{this.props.hasSelection
? <TableCell padding="checkbox" key="key-selection-column">
<Checkbox
indeterminate={this.props.selectedCount > 0 && this.props.selectedCount < this.props.dataCount}
checked={this.props.selectedCount === this.props.dataCount}
onChange={(event, checked) => this.props.onAllSelected && this.props.onAllSelected(checked)}
/>
</TableCell>
<Checkbox
indeterminate={this.props.selectedCount > 0 && this.props.selectedCount < this.props.dataCount}
checked={this.props.selectedCount === this.props.dataCount}
onChange={(event, checked) => this.props.onAllSelected && this.props.onAllSelected(checked)}
/>
</TableCell>
: this.props.showActionsColumn &&
<TableCell key="key-actions-column">
<TableSortLabel>{this.props.localization.actions}</TableSortLabel>
<TableSortLabel>{this.props.localization.actions}</TableSortLabel>
</TableCell>
}
{this.props.columns.filter(columnDef => { return !columnDef.hidden }).map((columnDef, index, arr) => (
<TableCell
<TableCell
key={columnDef.tableData.id}
numeric={['numeric'].indexOf(columnDef.type) !== -1}
>
Expand All @@ -51,7 +51,6 @@ class MTableHeader extends React.Component {
}
}


MTableHeader.defaultProps = {
dataCount: 0,
hasSelection: false,
Expand All @@ -70,7 +69,7 @@ MTableHeader.propTypes = {
onAllSelected: PropTypes.func,
onOrderChanged: PropTypes.func,
orderBy: PropTypes.number,
orderDirection: PropTypes.string,
orderDirection: PropTypes.string
};

export default MTableHeader;
20 changes: 10 additions & 10 deletions src/m-table-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ class MTableToolbar extends React.Component {

exportCsv = () => {
const columns = this.props.columns
.filter(columnDef => {
.filter(columnDef => {
return !columnDef.hidden && columnDef.field;
});
});

const data = this.props.renderData.map(rowData =>
columns.map(columnDef => rowData[columnDef.field])
);

const builder = new CsvBuilder((this.props.title || 'data') + ".csv")
const builder = new CsvBuilder((this.props.title || 'data') + '.csv') // eslint-disable-line no-unused-vars
.setColumns(columns.map(columnDef => columnDef.title))
.addRows(data)
.exportFile();

this.setState({exportButtonAnchorEl: null});
}

Expand Down Expand Up @@ -70,7 +70,7 @@ class MTableToolbar extends React.Component {
open={Boolean(this.state.columnsButtonAnchorEl)}
onClose={() => this.setState({ columnsButtonAnchorEl: null }) }>
{
this.props.columns.map((col, index) => {
this.props.columns.map((col, index) => {
return (
<MenuItem key={col.tableData.id}>
<FormControlLabel
Expand All @@ -93,7 +93,7 @@ class MTableToolbar extends React.Component {
</Menu>
</span>
}
{this.props.exportButton &&
{this.props.exportButton &&
<span>
<Tooltip title="Export">
<IconButton
Expand All @@ -111,7 +111,7 @@ class MTableToolbar extends React.Component {
Export as CSV
</MenuItem>
</Menu>
</span>
</span>

}
<MTableActions actions={this.props.actions && this.props.actions.filter(a => { return a.isFreeAction })}/>
Expand Down Expand Up @@ -157,7 +157,7 @@ MTableToolbar.defaultProps = {
search: true,
searchText: '',
selectedRows: [],
title: 'No Title!',
title: 'No Title!'
};

MTableToolbar.propTypes = {
Expand All @@ -170,7 +170,7 @@ MTableToolbar.propTypes = {
search: PropTypes.bool.isRequired,
searchText: PropTypes.string.isRequired,
selectedRows: PropTypes.array,
title: PropTypes.string.isRequired,
title: PropTypes.string.isRequired
};

const styles = theme => ({
Expand Down
14 changes: 7 additions & 7 deletions src/material-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class MaterialTable extends React.Component {
{props.options.toolbar &&
<MTableToolbar
actions={props.actions}
selectedRows={this.state.selectedCount > 0 ? this.state.data.filter(a => { return a.tableData.checked }) : []}
selectedRows={this.state.selectedCount > 0 ? this.state.data.filter(a => { return a.tableData.checked }) : []}
columns={this.state.columns}
columnsButton={props.options.columnsButton}
exportButton={props.options.exportButton}
Expand All @@ -201,13 +201,13 @@ class MaterialTable extends React.Component {
searchText={this.state.searchText}
title={props.title}
onSearchChanged={searchText => this.setState({searchText}, () => this.setData())}
onColumnsChanged={columns => this.setState({columns})}
localization={Object.assign(MaterialTable.defaultProps.localization, this.props.localization)}
onColumnsChanged={columns => this.setState({columns})}
localization={Object.assign(MaterialTable.defaultProps.localization, this.props.localization)}
/>
}
<div style={{overflowX: 'auto'}}>
<Table>
<MTableHeader
<MTableHeader
localization={Object.assign(MaterialTable.defaultProps.localization, this.props.localization)}
columns={this.state.columns}
hasSelection={props.options.selection}
Expand All @@ -230,7 +230,7 @@ class MaterialTable extends React.Component {
});
}}
/>
<MTableBody
<MTableBody
actions={props.actions}
renderData={this.state.renderData}
currentPage={this.state.currentPage}
Expand Down Expand Up @@ -290,7 +290,7 @@ MaterialTable.propTypes = {
icon: PropTypes.string.isRequired,
isFreeAction: PropTypes.bool,
tooltip: PropTypes.string,
onClick: PropTypes.func.isRequired,
onClick: PropTypes.func.isRequired
})),
columns: PropTypes.arrayOf(PropTypes.shape({
cellStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
Expand Down Expand Up @@ -320,4 +320,4 @@ MaterialTable.propTypes = {
})
};

export default MaterialTable;
export default MaterialTable;

0 comments on commit ecddb07

Please sign in to comment.