Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1338 from metasfresh/dev-1199
Browse files Browse the repository at this point in the history
Force closing included view only if selection is empty
  • Loading branch information
metas-mk committed Nov 13, 2017
2 parents 3ac2508 + bd971d8 commit c760c88
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,21 +345,24 @@ class Table extends Component {
})
}

deselectProduct = (id) => {
deselectProduct = id => {
const { dispatch, tabInfo, type, viewId } = this.props;
const index = this.state.selected.indexOf(id);
const { selected } = this.state;

this.setState(update(this.state, {
selected: {$splice: [[index, 1]]}
}), () => {
const index = selected.indexOf(id);
const newSelected = update(selected, { $splice: [[index, 1]] });

this.setState({ selected: newSelected }, () => {
if (tabInfo) {
dispatch(selectTableItems({
windowType: type,
viewId,
ids: this.state.selected,
ids: newSelected
}));
}
})
});

return newSelected;
}

deselectAllProducts = (cb) => {
Expand Down Expand Up @@ -568,8 +571,8 @@ class Table extends Component {

if(selectMore){
if(isSelected){
this.deselectProduct(id);
return false;
const newSelected = this.deselectProduct(id);
return newSelected.length > 0;
}else{
this.selectProduct(id);
}
Expand Down Expand Up @@ -933,10 +936,12 @@ class Table extends Component {
const selected = this.handleClick(
e, item[keyProperty]
);

if (openIncludedViewOnSelect) {
showIncludedViewOnSelect({
showIncludedView: selected &&
item.supportIncludedViews,
forceClose: !selected,

windowType: item.supportIncludedViews ? (
item.includedView.windowType ||
Expand Down

0 comments on commit c760c88

Please sign in to comment.