Skip to content

Commit

Permalink
published version 1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnb committed Apr 11, 2018
1 parent 16fc107 commit f6e5090
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mui-datatables",
"version": "1.1.4",
"version": "1.1.5",
"description": "Datatables for React using Material-UI",
"main": "dist/index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class MUIDataTable extends React.Component {
this.setState(prevState => {
const filterList = cloneDeep(prevState.filterList);
const filterPos = filterList[index].indexOf(column);

switch (type) {
case "checkbox":
filterPos >= 0 ? filterList[index].splice(filterPos, 1) : filterList[index].push(column);
Expand Down
20 changes: 10 additions & 10 deletions src/MUIDataTableFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Input, { InputLabel } from "material-ui/Input";
import { MenuItem } from "material-ui/Menu";
import Select from "material-ui/Select";
import Checkbox from "material-ui/Checkbox";
import { ListItemText } from 'material-ui/List';
import { ListItemText } from "material-ui/List";
import { withStyles } from "material-ui/styles";

export const defaultFilterStyles = {
Expand Down Expand Up @@ -123,7 +123,7 @@ class MUIDataTableFilter extends React.Component {
const value = event.target.value === "All" ? "" : event.target.value;
this.props.onFilterUpdate(index, value, "dropdown");
};

handleMultiselectChange = (index, column) => {
this.props.onFilterUpdate(index, column, "multiselect");
};
Expand Down Expand Up @@ -182,8 +182,7 @@ class MUIDataTableFilter extends React.Component {
value={filterList[index].toString() || "All"}
name={column.name}
onChange={event => this.handleDropdownChange(event, index)}
input={<Input name={column.name} id={column.name} />}
>
input={<Input name={column.name} id={column.name} />}>
<MenuItem value="All" key={0}>
All
</MenuItem>
Expand All @@ -201,7 +200,7 @@ class MUIDataTableFilter extends React.Component {
</div>
);
}

renderMultiselect(columns) {
const { classes, filterData, filterList, options } = this.props;

Expand All @@ -215,11 +214,10 @@ class MUIDataTableFilter extends React.Component {
<Select
multiple
value={filterList[index] || []}
renderValue={selected => selected.join(', ')}
renderValue={selected => selected.join(", ")}
name={column.name}
onChange={event => this.handleMultiselectChange(index, event.target.value)}
input={<Input name={column.name} id={column.name} />}
>
input={<Input name={column.name} id={column.name} />}>
{filterData[index].map((filterColumn, filterIndex) => (
<MenuItem value={filterColumn} key={filterIndex + 1}>
<Checkbox
Expand All @@ -231,7 +229,7 @@ class MUIDataTableFilter extends React.Component {
}}
/>
<ListItemText primary={filterColumn} />
</MenuItem>
</MenuItem>
))}
</Select>
</FormControl>
Expand Down Expand Up @@ -264,7 +262,9 @@ class MUIDataTableFilter extends React.Component {
</div>
<div className={classes.filtersSelected} />
</div>
{options.filterType === "checkbox" ? this.renderCheckbox(columns) : options.filterType === "multiselect" ? this.renderMultiselect(columns) : this.renderSelect(columns)}
{options.filterType === "checkbox"
? this.renderCheckbox(columns)
: options.filterType === "multiselect" ? this.renderMultiselect(columns) : this.renderSelect(columns)}
</div>
);
}
Expand Down
8 changes: 5 additions & 3 deletions test/MUIDataTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ describe("<MUIDataTable />", function() {
let data;
let displayData;
let columns;
let renderCities = (index, value, updateValue) => <Cities value={value} index={index} change={event => updateValue(event)} />;
let renderName = (index, value) => value.split(" ")[1]+", "+value.split(" ")[0];
let renderCities = (index, value, updateValue) => (
<Cities value={value} index={index} change={event => updateValue(event)} />
);
let renderName = (index, value) => value.split(" ")[1] + ", " + value.split(" ")[0];

before(() => {
columns = [
Expand Down Expand Up @@ -378,7 +380,7 @@ describe("<MUIDataTable />", function() {
const state = shallowWrapper.state();
assert.deepEqual(state.selectedRows, [0]);
});

it("should update value when calling updateValue method in customRender", () => {
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />).dive();
const instance = shallowWrapper.instance();
Expand Down
4 changes: 2 additions & 2 deletions test/MUIDataTableFilter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ describe("<MUIDataTableFilter />", function() {
const actualResult = mountWrapper.find(Select);
assert.strictEqual(actualResult.length, 0);
});

it("should data table filter view with checkbox selects if filterType = 'multiselect'", () => {
const options = { filterType: "multiselect" };
const filterList = [["Joe James","John Walsh"], [], [], []];
const filterList = [["Joe James", "John Walsh"], [], [], []];

const mountWrapper = mount(
<MUIDataTableFilter columns={columns} filterData={filterData} filterList={filterList} options={options} />,
Expand Down

0 comments on commit f6e5090

Please sign in to comment.