Merge pull request #764 from KaleoSoftware/fix-table-multiselect
Make Table multi-selectable againold
commit
d9e77fc90d
|
@ -42,11 +42,11 @@ const factory = (TableHead, TableRow) => {
|
|||
|
||||
handleRowSelect = (index) => {
|
||||
if (this.props.onSelect) {
|
||||
let newSelection = [];
|
||||
let newSelection = [...this.props.selected];
|
||||
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 = position !== -1
|
||||
? newSelection.filter((el, idx) => idx !== position)
|
||||
: newSelection.concat([index]);
|
||||
} else {
|
||||
newSelection = [index];
|
||||
|
|
|
@ -33,6 +33,8 @@ var _TableRow2 = _interopRequireDefault(_TableRow);
|
|||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
@ -67,11 +69,11 @@ var factory = function factory(TableHead, TableRow) {
|
|||
}
|
||||
}, _this.handleRowSelect = function (index) {
|
||||
if (_this.props.onSelect) {
|
||||
var newSelection = [];
|
||||
var newSelection = [].concat(_toConsumableArray(_this.props.selected));
|
||||
if (_this.props.multiSelectable) {
|
||||
(function () {
|
||||
var position = _this.props.selected.indexOf(index);
|
||||
newSelection = _this.props.selected.indexOf(index) !== -1 ? _this.props.selected.filter(function (el, idx) {
|
||||
newSelection = position !== -1 ? newSelection.filter(function (el, idx) {
|
||||
return idx !== position;
|
||||
}) : newSelection.concat([index]);
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue