Web: People: GroupAction: fixed reset of the selected group in tree when updating (or following a link) of the group edit page
This commit is contained in:
parent
7a0c6ef772
commit
f67d0ca5e1
@ -19,7 +19,12 @@ import {
|
|||||||
resetGroup,
|
resetGroup,
|
||||||
updateGroup,
|
updateGroup,
|
||||||
} from "../../../../../store/group/actions";
|
} from "../../../../../store/group/actions";
|
||||||
import { selectGroup, setFilter } from "../../../../../store/people/actions";
|
import {
|
||||||
|
selectGroup,
|
||||||
|
setFilter,
|
||||||
|
setSelectGroup,
|
||||||
|
} from "../../../../../store/people/actions";
|
||||||
|
import { getSelectedGroupId } from "../../../../../store/people/selectors";
|
||||||
|
|
||||||
import { GUID_EMPTY } from "../../../../../helpers/constants";
|
import { GUID_EMPTY } from "../../../../../helpers/constants";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
@ -91,6 +96,14 @@ class SectionBodyContent extends React.Component {
|
|||||||
this.state = this.mapPropsToState();
|
this.state = this.mapPropsToState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const { selectedGroup, group, setSelectGroup } = this.props;
|
||||||
|
const { id } = group;
|
||||||
|
if (!selectedGroup || selectedGroup !== id) {
|
||||||
|
setSelectGroup(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mapPropsToState = () => {
|
mapPropsToState = () => {
|
||||||
const { group, users, groups, t } = this.props;
|
const { group, users, groups, t } = this.props;
|
||||||
const buttonLabel = group ? t("SaveButton") : t("AddButton");
|
const buttonLabel = group ? t("SaveButton") : t("AddButton");
|
||||||
@ -520,6 +533,7 @@ function mapStateToProps(state) {
|
|||||||
currentModuleName,
|
currentModuleName,
|
||||||
filter: state.people.filter,
|
filter: state.people.filter,
|
||||||
isLoaded,
|
isLoaded,
|
||||||
|
selectedGroup: getSelectedGroupId(state),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,4 +543,5 @@ export default connect(mapStateToProps, {
|
|||||||
updateGroup,
|
updateGroup,
|
||||||
selectGroup,
|
selectGroup,
|
||||||
setFilter,
|
setFilter,
|
||||||
|
setSelectGroup,
|
||||||
})(withRouter(withTranslation()(SectionBodyContent)));
|
})(withRouter(withTranslation()(SectionBodyContent)));
|
||||||
|
@ -174,6 +174,13 @@ export function setIsEditingForm(isEdit) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setSelectGroup(groupId) {
|
||||||
|
return {
|
||||||
|
type: SELECT_GROUP,
|
||||||
|
groupId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function fetchSelectorUsers() {
|
export function fetchSelectorUsers() {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
api.people.getSelectorUserList().then((data) => {
|
api.people.getSelectorUserList().then((data) => {
|
||||||
@ -235,10 +242,7 @@ function fetchPeopleByFilter(dispatch, filter) {
|
|||||||
return api.people.getUserList(filterData).then((data) => {
|
return api.people.getUserList(filterData).then((data) => {
|
||||||
filterData.total = data.total;
|
filterData.total = data.total;
|
||||||
dispatch(setFilter(filterData));
|
dispatch(setFilter(filterData));
|
||||||
dispatch({
|
dispatch(setSelectGroup(filterData.group));
|
||||||
type: SELECT_GROUP,
|
|
||||||
groupId: filterData.group,
|
|
||||||
});
|
|
||||||
return dispatch(setUsers(data.items));
|
return dispatch(setUsers(data.items));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -456,3 +456,7 @@ export const getIsEmptyGroup = createSelector(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getSelectedGroupId = (state) => {
|
||||||
|
return state.people.selectedGroup;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user