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 #691 from metasfresh/dev-682
Browse files Browse the repository at this point in the history
#682 Selection strategy changed
  • Loading branch information
damianprzygodzki committed Apr 26, 2017
2 parents 37e029a + 75c00b8 commit c9a1242
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/components/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Window extends Component {
queryOnActivate={queryOnActivate}
supportQuickInput={supportQuickInput}
tabInfo={tabsInfo && tabsInfo[tabid]}
disconnectFromState={true}
/>
)
})}
Expand Down
24 changes: 13 additions & 11 deletions src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class DocumentList extends Component {
componentWillReceiveProps(props) {
const {
windowType, defaultViewId, defaultSort, defaultPage, selected,
inBackground, dispatch, includedView, selectedWindowType
inBackground, dispatch, includedView, selectedWindowType,
disconnectFromState
} = props;
const {page, sort, viewId, cachedSelection, layout} = this.state;

Expand All @@ -89,7 +90,7 @@ class DocumentList extends Component {
filters: null,
viewId: null
}, () => {
dispatch(selectTableItems([], null))
!disconnectFromState && dispatch(selectTableItems([], null))
this.fetchLayoutAndData();
});
}
Expand Down Expand Up @@ -133,7 +134,7 @@ class DocumentList extends Component {
) {
if(!inBackground){
// In case of preventing cached selection restore
cachedSelection &&
cachedSelection && !disconnectFromState &&
dispatch(selectTableItems(cachedSelection, windowType))
this.setState({
cachedSelection: undefined
Expand Down Expand Up @@ -425,7 +426,7 @@ class DocumentList extends Component {
windowType, open, closeOverlays, selected, inBackground,
fetchQuickActionsOnInit, isModal, processStatus, readonly,
includedView, children, isIncluded, disablePaginationShortcuts,
notfound
notfound, disconnectFromState
} = this.props;

const hasIncluded = layout && layout.supportIncludedView &&
Expand Down Expand Up @@ -498,28 +499,29 @@ class DocumentList extends Component {
keyProperty="id"
onDoubleClick={(id) =>
!isIncluded && this.redirectToDocument(id)}
isModal={isModal}
isIncluded={isIncluded}
size={data.size}
pageLength={this.pageLength}
handleChangePage={this.handleChangePage}
page={page}
mainTable={true}
updateDocList={this.fetchLayoutAndData}
sort={this.sortData}
orderBy={data.orderBy}
tabIndex={0}
open={open}
closeOverlays={closeOverlays}
indentSupported={layout.supportTree}
disableOnClickOutside={clickOutsideLock}
defaultSelected={cachedSelection ?
cachedSelection : selected}
queryLimitHit={data.queryLimitHit}
doesSelectionExist={this.doesSelectionExist}
disconnectFromState={disconnectFromState}
isIncluded={isIncluded}
isModal={isModal}
disablePaginationShortcuts={
disablePaginationShortcuts}
inBackground={inBackground}
disablePaginationShortcuts=
{disablePaginationShortcuts}
closeOverlays={closeOverlays}
open={open}
page={page}
>
{layout.supportAttributes && !isIncluded &&
!hasIncluded &&
Expand Down
3 changes: 2 additions & 1 deletion src/components/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Header extends Component {

componentWillUnmount() {
document.removeEventListener('scroll', this.handleScroll);
this.toggleScrollScope(false);
}

componentWillUpdate = (nextProps) => {
Expand Down Expand Up @@ -503,7 +504,7 @@ class Header extends Component {

<GlobalContextShortcuts
handleSidelistToggle={(id) =>
this.handleSidelistToggle(id, sideListTab)}
showSidelist && this.handleSidelistToggle(id, sideListTab)}
handleMenuOverlay={isMenuOverlayShow ?
() => this.handleMenuOverlay('', '') :
() => this.closeOverlays('',
Expand Down
4 changes: 3 additions & 1 deletion src/components/header/SideList.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class SideList extends Component {
(pagination && pagination.windowType === windowType) ?
pagination.page : null
}
selected={[docId]}
disconnectFromState={true}
{...{open, windowType, closeOverlays, closeSideList,
isSideListShow}}
/>
Expand Down Expand Up @@ -92,7 +94,7 @@ class SideList extends Component {
return (
<div
ref={(c) => this.panel = c}
className="order-list-panel overlay-shadow order-list-panel-open"
className="order-list-panel overlay-shadow order-list-panel-open js-not-unselect"
>
<div className="order-list-panel-body">
<div className="order-list-nav">
Expand Down
1 change: 0 additions & 1 deletion src/components/shortcuts/GlobalContextShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class GlobalContextShortcuts extends Component {
case 'OPEN_INBOX_MENU':
event.preventDefault();
closeOverlays('', ()=> handleInboxOpen(true));

break;
case 'OPEN_SIDEBAR_MENU_0':
event.preventDefault();
Expand Down
32 changes: 18 additions & 14 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,28 @@ class Table extends Component {
this.getIndentData(true);
}

componentWillUpdate(nextProps, nextState) {
const {dispatch, type} = this.props;

if(
JSON.stringify(nextState.selected) !==
JSON.stringify(this.state.selected)
){
dispatch(selectTableItems(nextState.selected, type));
}
}
componentDidUpdate(prevProps, prevState) {
const {
mainTable, open, rowData, defaultSelected, disconnectFromState,
dispatch, type
} = this.props;

componentDidUpdate(prevProps) {
const {mainTable, open, rowData, defaultSelected} = this.props;
const {
selected
} = this.state;

if(mainTable && open){
this.table.focus();
}

if(
!disconnectFromState &&
(JSON.stringify(prevState.selected) !==
JSON.stringify(selected))
){
dispatch(selectTableItems(selected, type));
}

if(
JSON.stringify(prevProps.rowData) !=
JSON.stringify(rowData)
Expand Down Expand Up @@ -148,13 +152,13 @@ class Table extends Component {
}

selectProduct = (id, idFocused, idFocusedDown) => {
const {dispatch, type} = this.props;
const {dispatch, type, disconnectFromState} = this.props;

this.setState(prevState => ({
selected: prevState.selected.concat([id])
}), () => {
const {selected} = this.state;
dispatch(selectTableItems(selected, type))
!disconnectFromState && dispatch(selectTableItems(selected, type))
this.triggerFocus(idFocused, idFocusedDown);
})
}
Expand Down

0 comments on commit c9a1242

Please sign in to comment.