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

Commit

Permalink
#630 Removing includedView
Browse files Browse the repository at this point in the history
  • Loading branch information
damianprzygodzki committed Apr 18, 2017
1 parent 85ed309 commit 8fec2cd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/actions/WindowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ export function handleProcessResponse(response, type, id, successCallback) {
action.windowId, action.viewId
));
break;
case 'closeIncludedView':
dispatch(setListIncludedView());
break;
}
}

Expand Down
31 changes: 23 additions & 8 deletions src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
import {
setSorting,
setPagination,
setListId
setListId,
setListIncludedView
} from '../../actions/ListActions';

import {
Expand Down Expand Up @@ -70,9 +71,9 @@ class DocumentList extends Component {
componentWillReceiveProps(props) {
const {
windowType, defaultViewId, defaultSort, defaultPage, selected,
inBackground, dispatch
inBackground, dispatch, includedView, selectedWindowType
} = props;
const {page, sort, viewId, cachedSelection} = this.state;
const {page, sort, viewId, cachedSelection, layout} = this.state;

/*
* If we browse list of docs, changing type of Document
Expand Down Expand Up @@ -129,19 +130,32 @@ class DocumentList extends Component {
inBackground != this.props.inBackground
) {
if(!inBackground){
dispatch(selectTableItems(cachedSelection, windowType))
// In case of preventing cached selection restore
cachedSelection &&
dispatch(selectTableItems(cachedSelection, windowType))
}else{
this.setState({
cachedSelection: selected
})
}
}


/*
* When the selection of unfocused table changes
*/
if(
selectedWindowType === windowType &&
JSON.stringify(selected) != JSON.stringify(this.props.selected) &&
layout && layout.supportIncludedView &&
includedView && includedView.windowType && includedView.viewId
){
//TODO: we need here close includedView when supportIncludedView will be available
// There is no need to restore cached selection in that case
this.setState({
cachedSelection: null
}, () => {
dispatch(setListIncludedView());
})
}
}

Expand Down Expand Up @@ -379,10 +393,10 @@ class DocumentList extends Component {
includedView, children, isIncluded
} = this.props;

const hasIncluded = true && includedView &&
includedView.windowType && includedView.viewId;
const hasIncluded = layout && layout.supportIncludedView &&
includedView && includedView.windowType && includedView.viewId;
const selectionValid = this.doesSelectionExist(selected, hasIncluded);
hasIncluded && console.log(selected)

if(layout && data) {
return (
<div
Expand Down Expand Up @@ -465,6 +479,7 @@ class DocumentList extends Component {
inBackground={inBackground}
>
{layout.supportAttributes && !isIncluded &&
!layout.supportIncludedView &&
<DataLayoutWrapper
className="table-flex-wrapper attributes-selector js-not-unselect"
entity="documentView"
Expand Down
8 changes: 6 additions & 2 deletions src/containers/DocList.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DocList extends Component {
render() {
const {
windowType, breadcrumb, query, modal, selected, rawModal,
indicator, processStatus, includedView
indicator, processStatus, includedView, selectedWindowType
} = this.props;

const {
Expand Down Expand Up @@ -109,6 +109,7 @@ class DocList extends Component {
windowType={parseInt(rawModal.type)}
defaultViewId={rawModal.viewId}
selected={selected}
selectedWindowType={selectedWindowType}
setModalTitle={this.setModalTitle}
isModal={true}
processStatus={processStatus}
Expand All @@ -135,6 +136,7 @@ class DocList extends Component {
defaultPage={parseInt(query.page)}
refType={query.refType}
refId={query.refId}
selectedWindowType={selectedWindowType}
selected={selected}
inBackground={rawModal.visible}
fetchQuickActionsOnInit={true}
Expand Down Expand Up @@ -167,12 +169,14 @@ function mapStateToProps(state) {
modal,
rawModal,
selected,
selectedWindowType,
latestNewDocument,
indicator
} = windowHandler || {
modal: false,
rawModal: false,
selected: [],
selectedWindowType: null,
latestNewDocument: null,
indicator: ''
}
Expand Down Expand Up @@ -203,7 +207,7 @@ function mapStateToProps(state) {

return {
modal, breadcrumb, pathname, selected, indicator, includedView,
latestNewDocument, rawModal, processStatus
latestNewDocument, rawModal, processStatus, selectedWindowType
}
}

Expand Down

0 comments on commit 8fec2cd

Please sign in to comment.