mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
setting changed on actual map change
This commit is contained in:
parent
34f98fb08b
commit
1a00b98ba3
3 changed files with 17 additions and 8 deletions
|
@ -13,13 +13,15 @@ import { Stickers } from '~/containers/map/Stickers';
|
||||||
import { KmMarks } from '~/containers/map/KmMarks';
|
import { KmMarks } from '~/containers/map/KmMarks';
|
||||||
|
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
import { selectEditorEditing } from '~/redux/editor/selectors';
|
import { selectEditorEditing, selectEditorMode } from '~/redux/editor/selectors';
|
||||||
|
import { MODES } from '~/constants/modes';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
provider: selectMapProvider(state),
|
provider: selectMapProvider(state),
|
||||||
route: selectMapRoute(state),
|
route: selectMapRoute(state),
|
||||||
stickers: selectMapStickers(state),
|
stickers: selectMapStickers(state),
|
||||||
editing: selectEditorEditing(state),
|
editing: selectEditorEditing(state),
|
||||||
|
mode: selectEditorMode(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
|
@ -37,6 +39,7 @@ const MapUnconnected: React.FC<IProps> = ({
|
||||||
provider,
|
provider,
|
||||||
stickers,
|
stickers,
|
||||||
editing,
|
editing,
|
||||||
|
mode,
|
||||||
|
|
||||||
mapClicked,
|
mapClicked,
|
||||||
mapSetSticker,
|
mapSetSticker,
|
||||||
|
@ -44,11 +47,11 @@ const MapUnconnected: React.FC<IProps> = ({
|
||||||
}) => {
|
}) => {
|
||||||
const onClick = React.useCallback(
|
const onClick = React.useCallback(
|
||||||
event => {
|
event => {
|
||||||
if (!MainMap.clickable) return;
|
if (!MainMap.clickable || mode === MODES.NONE) return;
|
||||||
|
|
||||||
mapClicked(event.latlng);
|
mapClicked(event.latlng);
|
||||||
},
|
},
|
||||||
[mapClicked]
|
[mapClicked, mode]
|
||||||
);
|
);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { simplify } from '~/utils/simplify';
|
||||||
import {
|
import {
|
||||||
editorHideRenderer,
|
editorHideRenderer,
|
||||||
editorSetChanged,
|
editorSetChanged,
|
||||||
editorSetEditing,
|
|
||||||
editorSetMode,
|
editorSetMode,
|
||||||
editorSetReady,
|
editorSetReady,
|
||||||
editorSetRenderer,
|
editorSetRenderer,
|
||||||
|
@ -40,7 +39,7 @@ import {
|
||||||
import { selectMap, selectMapRoute } from '../map/selectors';
|
import { selectMap, selectMapRoute } from '../map/selectors';
|
||||||
import { selectUser } from '../user/selectors';
|
import { selectUser } from '../user/selectors';
|
||||||
import { LOGOS } from '~/constants/logos';
|
import { LOGOS } from '~/constants/logos';
|
||||||
import { loadMapSaga, startEmptyEditorSaga, loadMapFromPath } from '../map/sagas';
|
import { loadMapFromPath } from '../map/sagas';
|
||||||
import { mapClicked, mapSetRoute } from '../map/actions';
|
import { mapClicked, mapSetRoute } from '../map/actions';
|
||||||
import { MAP_ACTIONS } from '../map/constants';
|
import { MAP_ACTIONS } from '../map/constants';
|
||||||
import { OsrmRouter } from '~/utils/osrm';
|
import { OsrmRouter } from '~/utils/osrm';
|
||||||
|
@ -56,12 +55,10 @@ const hideLoader = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function* stopEditingSaga() {
|
function* stopEditingSaga() {
|
||||||
const { changed, editing, mode }: ReturnType<typeof selectEditor> = yield select(selectEditor);
|
const { changed, mode }: ReturnType<typeof selectEditor> = yield select(selectEditor);
|
||||||
const { address_origin }: ReturnType<typeof selectMap> = yield select(selectMap);
|
const { address_origin }: ReturnType<typeof selectMap> = yield select(selectMap);
|
||||||
const { path } = getUrlData();
|
const { path } = getUrlData();
|
||||||
|
|
||||||
// if (!editing) return;
|
|
||||||
|
|
||||||
if (changed && mode !== MODES.CONFIRM_CANCEL) {
|
if (changed && mode !== MODES.CONFIRM_CANCEL) {
|
||||||
yield put(editorSetMode(MODES.CONFIRM_CANCEL));
|
yield put(editorSetMode(MODES.CONFIRM_CANCEL));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -313,7 +313,16 @@ function* sendSaveRequestSaga({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* setChanged() {
|
||||||
|
const { changed } = yield select(selectEditor);
|
||||||
|
if (changed) return;
|
||||||
|
|
||||||
|
yield put(editorSetChanged(true));
|
||||||
|
}
|
||||||
|
|
||||||
export function* mapSaga() {
|
export function* mapSaga() {
|
||||||
|
yield takeEvery([MAP_ACTIONS.SET_ROUTE, MAP_ACTIONS.SET_STICKER], setChanged);
|
||||||
|
|
||||||
// TODO: setChanged on set route, logo, provider, stickers
|
// TODO: setChanged on set route, logo, provider, stickers
|
||||||
yield takeEvery(EDITOR_ACTIONS.START_EDITING, startEditingSaga);
|
yield takeEvery(EDITOR_ACTIONS.START_EDITING, startEditingSaga);
|
||||||
yield takeEvery(EDITOR_ACTIONS.SET_ACTIVE_STICKER, setActiveStickerSaga);
|
yield takeEvery(EDITOR_ACTIONS.SET_ACTIVE_STICKER, setActiveStickerSaga);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue