Fix linter errors and refactor

old
Javi Velasco 2016-08-04 21:06:20 +02:00
parent 8e3d9bb93c
commit e597bc567f
1 changed files with 9 additions and 12 deletions

View File

@ -42,19 +42,16 @@ const factory = (TableHead, TableRow) => {
handleRowSelect = (index) => {
if (this.props.onSelect) {
const position = this.props.selected.indexOf(index);
let newSelected = [...this.props.selected];
if (position !== -1) {
newSelected = newSelected.filter((el,idx)=>{ return (idx != position); });
let newSelection = [];
if (this.props.multiSelectable) {
const position = this.props.selected.indexOf(index);
newSelection = this.props.selected.indexOf(index) !== -1
? this.props.selected.filter((el, idx) => idx !== position)
: newSelection.concat([index]);
} else {
newSelection = [index];
}
else if (this.props.multiSelectable) {
newSelected.push(index);
}
else {
newSelected = [index];
}
this.props.onSelect(newSelected);
this.props.onSelect(newSelection);
}
};