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,
|
||||
updateGroup,
|
||||
} 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 PropTypes from "prop-types";
|
||||
@ -91,6 +96,14 @@ class SectionBodyContent extends React.Component {
|
||||
this.state = this.mapPropsToState();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { selectedGroup, group, setSelectGroup } = this.props;
|
||||
const { id } = group;
|
||||
if (!selectedGroup || selectedGroup !== id) {
|
||||
setSelectGroup(id);
|
||||
}
|
||||
}
|
||||
|
||||
mapPropsToState = () => {
|
||||
const { group, users, groups, t } = this.props;
|
||||
const buttonLabel = group ? t("SaveButton") : t("AddButton");
|
||||
@ -520,6 +533,7 @@ function mapStateToProps(state) {
|
||||
currentModuleName,
|
||||
filter: state.people.filter,
|
||||
isLoaded,
|
||||
selectedGroup: getSelectedGroupId(state),
|
||||
};
|
||||
}
|
||||
|
||||
@ -529,4 +543,5 @@ export default connect(mapStateToProps, {
|
||||
updateGroup,
|
||||
selectGroup,
|
||||
setFilter,
|
||||
setSelectGroup,
|
||||
})(withRouter(withTranslation()(SectionBodyContent)));
|
||||
|
@ -174,6 +174,13 @@ export function setIsEditingForm(isEdit) {
|
||||
};
|
||||
}
|
||||
|
||||
export function setSelectGroup(groupId) {
|
||||
return {
|
||||
type: SELECT_GROUP,
|
||||
groupId,
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchSelectorUsers() {
|
||||
return (dispatch) => {
|
||||
api.people.getSelectorUserList().then((data) => {
|
||||
@ -235,10 +242,7 @@ function fetchPeopleByFilter(dispatch, filter) {
|
||||
return api.people.getUserList(filterData).then((data) => {
|
||||
filterData.total = data.total;
|
||||
dispatch(setFilter(filterData));
|
||||
dispatch({
|
||||
type: SELECT_GROUP,
|
||||
groupId: filterData.group,
|
||||
});
|
||||
dispatch(setSelectGroup(filterData.group));
|
||||
return dispatch(setUsers(data.items));
|
||||
});
|
||||
}
|
||||
|
@ -456,3 +456,7 @@ export const getIsEmptyGroup = createSelector(
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
export const getSelectedGroupId = (state) => {
|
||||
return state.people.selectedGroup;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user