Merge branch 'vmsoftware-dev' into dev
* vmsoftware-dev: Fix linter errors and refactor Fix multiselectable and unselect rows isues on Table componentold
commit
29d9664fe7
|
@ -2,3 +2,4 @@ build
|
|||
node_modules
|
||||
npm-debug.log
|
||||
.idea
|
||||
.DS_Store
|
|
@ -42,15 +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.splice(position, 1); }
|
||||
if (position !== -1 && this.props.multiSelectable) {
|
||||
newSelected.push(index);
|
||||
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 {
|
||||
newSelected = [index];
|
||||
newSelection = [index];
|
||||
}
|
||||
this.props.onSelect(newSelected);
|
||||
this.props.onSelect(newSelection);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -69,17 +69,22 @@ var factory = function factory(TableHead, TableRow) {
|
|||
}
|
||||
}, _this.handleRowSelect = function (index) {
|
||||
if (_this.props.onSelect) {
|
||||
var position = _this.props.selected.indexOf(index);
|
||||
var newSelected = [].concat(_toConsumableArray(_this.props.selected));
|
||||
if (position !== -1) {
|
||||
newSelected.splice(position, 1);
|
||||
}
|
||||
if (position !== -1 && _this.props.multiSelectable) {
|
||||
newSelected.push(index);
|
||||
} else {
|
||||
newSelected = [index];
|
||||
}
|
||||
_this.props.onSelect(newSelected);
|
||||
(function () {
|
||||
var position = _this.props.selected.indexOf(index);
|
||||
var newSelected = [].concat(_toConsumableArray(_this.props.selected));
|
||||
if (position !== -1) {
|
||||
newSelected = newSelected.filter(function (el, idx) {
|
||||
return idx != position;
|
||||
});
|
||||
} else {
|
||||
if (_this.props.multiSelectable) {
|
||||
newSelected.push(index);
|
||||
} else {
|
||||
newSelected = [index];
|
||||
}
|
||||
}
|
||||
_this.props.onSelect(newSelected);
|
||||
})();
|
||||
}
|
||||
}, _this.handleRowChange = function (index, key, value) {
|
||||
if (_this.props.onChange) {
|
||||
|
|
Loading…
Reference in New Issue