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 #513 from metasfresh/dev-349
Browse files Browse the repository at this point in the history
Dev 349
  • Loading branch information
damianprzygodzki authored Mar 8, 2017
2 parents 0ec9794 + f4877e6 commit 130d833
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/actions/WindowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ export function indicatorState(state) {

//SELECT ON TABLE

export function selectTableItems(ids) {
export function selectTableItems(ids, windowType) {
return {
type: types.SELECT_TABLE_ITEMS,
ids: ids
ids,
windowType
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DocumentList extends Component {
filters: null,
viewId: null
}, () => {
dispatch(selectTableItems([]))
dispatch(selectTableItems([], null))
this.fetchLayoutAndData();
});
}
Expand Down Expand Up @@ -113,7 +113,7 @@ class DocumentList extends Component {
inBackground != this.props.inBackground
) {
if(!inBackground){
dispatch(selectTableItems(cachedSelection))
dispatch(selectTableItems(cachedSelection, windowType))
}else{
this.setState({
cachedSelection: selected
Expand Down
13 changes: 8 additions & 5 deletions src/components/header/Header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component, PropTypes } from 'react';
import {connect} from 'react-redux';
import {push} from 'react-router-redux';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';

import logo from '../../assets/images/metasfresh_logo_green_thumb.png';

Expand Down Expand Up @@ -228,7 +227,7 @@ class Header extends Component {
docSummaryData, siteName, docNoData, docNo, docStatus, docStatusData,
windowType, dataId, breadcrumb, showSidelist, references, actions,
viewId, inbox, homemenu, selected, entity, query, attachments,
showIndicator, isDocumentNotSaved
showIndicator, isDocumentNotSaved, selectedWindowType
} = this.props;

const {
Expand Down Expand Up @@ -390,6 +389,7 @@ class Header extends Component {
handleClone={this.handleClone}
redirect={this.redirect}
selected={selected}
selectedWindowType={selectedWindowType}
entity={entity}
disableOnClickOutside={!isSubheaderShow}
query={query}
Expand Down Expand Up @@ -448,16 +448,19 @@ function mapStateToProps(state) {
}

const {
selected
selected,
selectedWindowType
} = windowHandler || {
selected: []
selected: [],
selectedWindowType: null
}

return {
selected,
viewId,
inbox,
homemenu
homemenu,
selectedWindowType
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/components/header/SubHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Subheader extends Component {

componentDidMount() {
const {
dispatch, windowType, dataId, selected, entity, query
dispatch, windowType, dataId, selected, selectedWindowType, entity,
query
} = this.props;

dispatch(setActions([]));
Expand All @@ -50,7 +51,13 @@ class Subheader extends Component {

if(windowType){
if(selected.length === 1 || dataId){
const id = dataId ? dataId : selected[0];
const id = dataId ? dataId : (selectedWindowType == windowType ? selected[0]: null);

if(!id){
dispatch(setAttachments([]));
dispatch(setReferences([]));
return;
}

/*
* These actions always are called in window context
Expand All @@ -75,7 +82,7 @@ class Subheader extends Component {

dispatch(
actionsRequest(
entity, windowType, dataId ? dataId : query && query.viewId, selected)
entity, windowType, dataId ? dataId : query && query.viewId, (selectedWindowType === windowType ? selected[0]: []))
).then((response) => {
dispatch(setActions(response.data.actions));
});
Expand Down
8 changes: 4 additions & 4 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class Table extends Component {
}

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

if(
JSON.stringify(nextState.selected) !==
JSON.stringify(this.state.selected)
){
dispatch(selectTableItems(nextState.selected));
dispatch(selectTableItems(nextState.selected, type));
}
}

Expand Down Expand Up @@ -142,13 +142,13 @@ class Table extends Component {
}

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

this.setState(prevState => ({
selected: prevState.selected.concat([id])
}), () => {
const {selected} = this.state;
dispatch(selectTableItems(selected))
dispatch(selectTableItems(selected, type))
this.triggerFocus(idFocused, idFocusedDown);
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/DocList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DocList extends Component {
dispatch(getWindowBreadcrumb(windowType));

if(latestNewDocument){
dispatch(selectTableItems([latestNewDocument]));
dispatch(selectTableItems([latestNewDocument], windowType));
dispatch(setLatestNewDocument(null));
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/reducers/windowHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const initialState = {
indicator: 'saved',
latestNewDocument: null,
viewId: null,
selected: []
selected: [],
selectedWindowType: null
}

export default function windowHandler(state = initialState, action) {
Expand Down Expand Up @@ -218,7 +219,8 @@ export default function windowHandler(state = initialState, action) {

case types.SELECT_TABLE_ITEMS:
return Object.assign({}, state, {
selected: action.ids
selected: action.ids,
selectedWindowType: action.windowType
})

// LATEST NEW DOCUMENT CACHE
Expand Down

0 comments on commit 130d833

Please sign in to comment.