From f325824da3d49c980dc1397f71d298d43850bcd6 Mon Sep 17 00:00:00 2001 From: muerwre Date: Fri, 14 Dec 2018 17:33:27 +0700 Subject: [PATCH] routes: hiding map dialog on map select --- src/components/dialogs/MapListMoreDialog.jsx | 11 ++++++++++- src/components/maps/RouteRow.jsx | 6 ++++-- src/redux/user/sagas.js | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/components/dialogs/MapListMoreDialog.jsx b/src/components/dialogs/MapListMoreDialog.jsx index 0798a5f..66ce734 100644 --- a/src/components/dialogs/MapListMoreDialog.jsx +++ b/src/components/dialogs/MapListMoreDialog.jsx @@ -8,12 +8,14 @@ import { searchSetDistance, searchSetTitle, searchSetTab, + setDialogActive, } from '$redux/user/actions'; import classnames from 'classnames'; import { Range } from 'rc-slider'; import { TABS } from '$constants/dialogs'; import { Icon } from '$components/panels/Icon'; +import { pushPath } from '$utils/history'; type Props = { ready: Boolean, @@ -31,10 +33,10 @@ type Props = { editing: Boolean, routes_sorted: Array, - searchSetAuthor: Function, searchSetDistance: Function, searchSetTitle: Function, searchSetTab: Function, + setDialogActive: Function, }; class Component extends React.Component { @@ -42,6 +44,11 @@ class Component extends React.Component { this.props.searchSetTitle(value); }; + openRoute = _id => { + pushPath(`/${_id}/${this.props.editing ? 'edit' : ''}`); + this.props.setDialogActive(false); + }; + render() { const { ready, @@ -130,6 +137,7 @@ class Component extends React.Component { editing={editing} {...route} key={route._id} + openRoute={this.openRoute} /> )) } @@ -164,6 +172,7 @@ const mapDispatchToProps = dispatch => bindActionCreators({ searchSetDistance, searchSetTitle, searchSetTab, + setDialogActive, }, dispatch); export const MapListMoreDialog = connect(mapStateToProps, mapDispatchToProps)(Component); diff --git a/src/components/maps/RouteRow.jsx b/src/components/maps/RouteRow.jsx index 00e1c95..ac1b76a 100644 --- a/src/components/maps/RouteRow.jsx +++ b/src/components/maps/RouteRow.jsx @@ -9,14 +9,16 @@ type Props = { created_at: String, _id: String, editing: Boolean, + + openRoute: Function, }; export const RouteRow = ({ - title, distance, created_at, _id, editing + title, distance, created_at, _id, editing, openRoute, }: Props) => (
pushPath(`/${_id}/${editing ? 'edit' : ''}`)} + onClick={() => openRoute(_id)} >
{title || _id} diff --git a/src/redux/user/sagas.js b/src/redux/user/sagas.js index a30b646..ca54fe7 100644 --- a/src/redux/user/sagas.js +++ b/src/redux/user/sagas.js @@ -461,9 +461,9 @@ function* openMapDialogSaga({ tab }) { return yield put(setDialogActive(false)); } - // if (tab !== current) { // if tab wasnt changed just update data - yield put(searchSetTab(tab)); - // } + if (tab !== current) { // if tab wasnt changed just update data + yield put(searchSetTab(tab)); + } yield put(setDialog(DIALOGS.MAP_LIST)); yield put(setDialogActive(true));