mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
added actions
This commit is contained in:
parent
d42586d9e0
commit
f8d2b6a5bd
6 changed files with 40 additions and 6 deletions
|
@ -7,7 +7,10 @@ import {
|
||||||
searchSetDistance,
|
searchSetDistance,
|
||||||
searchSetTitle,
|
searchSetTitle,
|
||||||
searchSetTab,
|
searchSetTab,
|
||||||
setDialogActive, mapsLoadMore,
|
setDialogActive,
|
||||||
|
mapsLoadMore,
|
||||||
|
dropRoute,
|
||||||
|
modifyRoute,
|
||||||
} from '$redux/user/actions';
|
} from '$redux/user/actions';
|
||||||
import { isMobile } from '$utils/window';
|
import { isMobile } from '$utils/window';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
@ -29,6 +32,8 @@ export interface IMapListDialogProps extends IRootState {
|
||||||
searchSetTitle: typeof searchSetTitle,
|
searchSetTitle: typeof searchSetTitle,
|
||||||
searchSetTab: typeof searchSetTab,
|
searchSetTab: typeof searchSetTab,
|
||||||
setDialogActive: typeof setDialogActive,
|
setDialogActive: typeof setDialogActive,
|
||||||
|
dropRoute: typeof dropRoute,
|
||||||
|
modifyRoute: typeof modifyRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMapListDialogState {
|
export interface IMapListDialogState {
|
||||||
|
@ -98,7 +103,14 @@ class Component extends React.Component<IMapListDialogProps, IMapListDialogState
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dropRoute = (): void => null;
|
dropRoute = (_id: string): void => {
|
||||||
|
this.props.dropRoute(_id);
|
||||||
|
};
|
||||||
|
|
||||||
|
modifyRoute = ({ _id, title, is_public }: { _id: string, title: string, is_public: boolean }): void => {
|
||||||
|
this.props.modifyRoute(_id, { title, is_public });
|
||||||
|
this.stopEditing();
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
|
@ -201,6 +213,7 @@ class Component extends React.Component<IMapListDialogProps, IMapListDialogState
|
||||||
showMenu={this.showMenu}
|
showMenu={this.showMenu}
|
||||||
showDropCard={this.showDropCard}
|
showDropCard={this.showDropCard}
|
||||||
dropRoute={this.dropRoute}
|
dropRoute={this.dropRoute}
|
||||||
|
modifyRoute={this.modifyRoute}
|
||||||
key={route._id}
|
key={route._id}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
|
@ -239,6 +252,8 @@ const mapDispatchToProps = dispatch => bindActionCreators({
|
||||||
searchSetTab,
|
searchSetTab,
|
||||||
setDialogActive,
|
setDialogActive,
|
||||||
mapsLoadMore,
|
mapsLoadMore,
|
||||||
|
dropRoute,
|
||||||
|
modifyRoute,
|
||||||
}, dispatch);
|
}, dispatch);
|
||||||
|
|
||||||
export const MapListDialog = connect(mapStateToProps, mapDispatchToProps)(Component);
|
export const MapListDialog = connect(mapStateToProps, mapDispatchToProps)(Component);
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const RouteRowDrop = ({
|
||||||
className="route-row"
|
className="route-row"
|
||||||
>
|
>
|
||||||
<div className="button-group">
|
<div className="button-group">
|
||||||
<div className="button" onClick={() => dropRoute(_id)}>Удалить</div>
|
<div className="button" onClick={dropRoute.bind(null, _id)}>Удалить</div>
|
||||||
<div className="button primary" onClick={stopEditing}>Отмена</div>
|
<div className="button primary" onClick={stopEditing}>Отмена</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Icon } from '$components/panels/Icon';
|
import { Icon } from '$components/panels/Icon';
|
||||||
import { Switch } from '$components/Switch';
|
import { Switch } from '$components/Switch';
|
||||||
|
import { MapListDialog } from "$components/dialogs/MapListDialog";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string;
|
title: string;
|
||||||
_id: string;
|
_id: string;
|
||||||
is_public: boolean,
|
is_public: boolean,
|
||||||
|
modifyRoute: typeof MapListDialog.modifyRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
@ -24,14 +26,21 @@ export class RouteRowEditor extends React.Component<Props, State> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
stopEditing = () => console.log();
|
stopEditing = () => {
|
||||||
|
const {
|
||||||
|
state: { title, is_public },
|
||||||
|
props: { _id }
|
||||||
|
} = this;
|
||||||
|
|
||||||
|
this.props.modifyRoute({ _id, title, is_public })
|
||||||
|
};
|
||||||
|
|
||||||
setPublic = () => this.setState({ is_public: !this.state.is_public });
|
setPublic = () => this.setState({ is_public: !this.state.is_public });
|
||||||
setTitle = ({ target: { value } }: { target: { value: string } }) => this.setState({ title: value });
|
setTitle = ({ target: { value } }: { target: { value: string } }) => this.setState({ title: value });
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
state: { title, is_public },
|
state: { title, is_public },
|
||||||
props: { _id }
|
|
||||||
} = this;
|
} = this;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -22,6 +22,7 @@ interface Props {
|
||||||
showMenu: typeof MapListDialog.showMenu,
|
showMenu: typeof MapListDialog.showMenu,
|
||||||
showDropCard: typeof MapListDialog.showDropCard,
|
showDropCard: typeof MapListDialog.showDropCard,
|
||||||
dropRoute: typeof MapListDialog.dropRoute,
|
dropRoute: typeof MapListDialog.dropRoute,
|
||||||
|
modifyRoute: typeof MapListDialog.modifyRoute,
|
||||||
|
|
||||||
is_editing_mode: 'edit' | 'drop',
|
is_editing_mode: 'edit' | 'drop',
|
||||||
}
|
}
|
||||||
|
@ -29,7 +30,7 @@ interface Props {
|
||||||
export const RouteRowWrapper = ({
|
export const RouteRowWrapper = ({
|
||||||
title, distance, _id, openRoute, tab, startEditing, showMenu,
|
title, distance, _id, openRoute, tab, startEditing, showMenu,
|
||||||
showDropCard, is_public, is_editing_target, is_menu_target, is_editing_mode,
|
showDropCard, is_public, is_editing_target, is_menu_target, is_editing_mode,
|
||||||
dropRoute, stopEditing,
|
dropRoute, stopEditing, modifyRoute,
|
||||||
}: Props): ReactElement<Props, null> => (
|
}: Props): ReactElement<Props, null> => (
|
||||||
<div
|
<div
|
||||||
className={classnames('route-row-wrapper', {
|
className={classnames('route-row-wrapper', {
|
||||||
|
@ -43,6 +44,7 @@ export const RouteRowWrapper = ({
|
||||||
title={title}
|
title={title}
|
||||||
_id={_id}
|
_id={_id}
|
||||||
is_public={is_public}
|
is_public={is_public}
|
||||||
|
modifyRoute={modifyRoute}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,3 +71,8 @@ export const mapsSetShift = (shift: number) => ({ type: ACTIONS.MAPS_SET_SHIFT,
|
||||||
|
|
||||||
export const setFeature = (features: { [x: string]: boolean }) => ({ type: ACTIONS.SET_FEATURE, features });
|
export const setFeature = (features: { [x: string]: boolean }) => ({ type: ACTIONS.SET_FEATURE, features });
|
||||||
export const setIsRouting = (is_routing: boolean) => ({ type: ACTIONS.SET_IS_ROUTING, is_routing });
|
export const setIsRouting = (is_routing: boolean) => ({ type: ACTIONS.SET_IS_ROUTING, is_routing });
|
||||||
|
|
||||||
|
export const dropRoute = (_id: string) => ({ type: ACTIONS.DROP_ROUTE, _id });
|
||||||
|
export const modifyRoute = (_id: string, { title, is_public }: { title: string, is_public: boolean }) => ({
|
||||||
|
type: ACTIONS.MODIFY_ROUTE, _id, title, is_public
|
||||||
|
});
|
||||||
|
|
|
@ -78,4 +78,7 @@ export const ACTIONS: IActions = {
|
||||||
|
|
||||||
SET_FEATURE: 'SET_FEATURE',
|
SET_FEATURE: 'SET_FEATURE',
|
||||||
SET_IS_ROUTING: 'SET_IS_ROUTING',
|
SET_IS_ROUTING: 'SET_IS_ROUTING',
|
||||||
|
|
||||||
|
DROP_ROUTE: 'DROP_ROUTE',
|
||||||
|
MODIFY_ROUTE: 'MODIFY_ROUTE',
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue