mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
forwards and backwards drawing
This commit is contained in:
parent
bbd7d6a89a
commit
ad676d5fde
11 changed files with 119 additions and 21 deletions
|
@ -146,3 +146,8 @@ export const editorRedo = () => ({
|
|||
export const editorCaptureHistory = () => ({
|
||||
type: EDITOR_ACTIONS.CAPTURE_HIPSTORY,
|
||||
});
|
||||
|
||||
export const editorSetDirection = (drawing_direction: IEditorState['drawing_direction']) => ({
|
||||
type: EDITOR_ACTIONS.SET_DIRECTION,
|
||||
drawing_direction,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
const P = 'EDITOR';
|
||||
|
||||
export const DRAWING_DIRECTIONS: Record<'FORWARDS' | 'BACKWARDS', 'forward' | 'backward'> = {
|
||||
FORWARDS: 'forward',
|
||||
BACKWARDS: 'backward',
|
||||
};
|
||||
|
||||
export const EDITOR_HISTORY_LENGTH = 100;
|
||||
|
||||
export const EDITOR_ACTIONS = {
|
||||
|
@ -54,4 +59,6 @@ export const EDITOR_ACTIONS = {
|
|||
UNDO: `${P}-UNDO`,
|
||||
REDO: `${P}-REDO`,
|
||||
CAPTURE_HIPSTORY: `${P}-CAPTURE_HIPSTORY`,
|
||||
|
||||
SET_DIRECTION: `${P}-SET_DIRECTION`,
|
||||
};
|
||||
|
|
|
@ -179,6 +179,14 @@ const setHistory = (
|
|||
},
|
||||
});
|
||||
|
||||
const setDirection = (
|
||||
state,
|
||||
{ drawing_direction }: ReturnType<typeof ACTIONS.editorSetDirection>
|
||||
): IEditorState => ({
|
||||
...state,
|
||||
drawing_direction,
|
||||
});
|
||||
|
||||
export const EDITOR_HANDLERS = {
|
||||
[EDITOR_ACTIONS.SET_EDITING]: setEditing,
|
||||
[EDITOR_ACTIONS.SET_CHANGED]: setChanged,
|
||||
|
@ -209,4 +217,6 @@ export const EDITOR_HANDLERS = {
|
|||
[EDITOR_ACTIONS.SET_NOMINATIM]: setNominatim,
|
||||
|
||||
[EDITOR_ACTIONS.SET_HISTORY]: setHistory,
|
||||
|
||||
[EDITOR_ACTIONS.SET_DIRECTION]: setDirection,
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@ import { EDITOR_HANDLERS } from './handlers';
|
|||
import { ILatLng } from '../map/types';
|
||||
import { INominatimResult } from '~/redux/types';
|
||||
import { IMapReducer } from '../map';
|
||||
import { DRAWING_DIRECTIONS } from './constants';
|
||||
|
||||
export interface IEditorHistoryItem {
|
||||
route: IMapReducer['route'];
|
||||
|
@ -35,6 +36,7 @@ export interface IEditorState {
|
|||
is_empty: boolean;
|
||||
is_published: boolean;
|
||||
is_routing: boolean;
|
||||
drawing_direction: typeof DRAWING_DIRECTIONS[keyof typeof DRAWING_DIRECTIONS];
|
||||
|
||||
features: {
|
||||
routing: boolean;
|
||||
|
@ -63,6 +65,7 @@ export interface IEditorState {
|
|||
processing: boolean;
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
history: {
|
||||
records: IEditorHistoryItem[];
|
||||
position: number;
|
||||
|
@ -84,13 +87,16 @@ export const EDITOR_INITIAL_STATE = {
|
|||
estimated: 0,
|
||||
speed: 15,
|
||||
activeSticker: { set: null, sticker: null },
|
||||
drawing_direction: DRAWING_DIRECTIONS.FORWARDS,
|
||||
|
||||
is_published: false,
|
||||
is_empty: true,
|
||||
is_routing: false,
|
||||
|
||||
router: {
|
||||
waypoints: [],
|
||||
points: [],
|
||||
},
|
||||
is_published: false,
|
||||
is_empty: true,
|
||||
is_routing: false,
|
||||
|
||||
features: {
|
||||
routing: false,
|
||||
|
|
|
@ -9,3 +9,4 @@ export const selectEditorRenderer = (state: IState) => state.editor.renderer;
|
|||
export const selectEditorRouter = (state: IState) => state.editor.router;
|
||||
export const selectEditorDistance = (state: IState) => state.editor.distance;
|
||||
export const selectEditorNominatim = (state: IState) => state.editor.nominatim;
|
||||
export const selectEditorDirection = (state: IState) => state.editor.drawing_direction;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue