From 143f8f58fc8ddbef59c1d71b54ecef950569585f Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 26 Apr 2022 16:28:09 +0300 Subject: [PATCH 1/6] Cadastrapp changes to support new SidebarMenu plugin --- js/extension/cadastrapp.css | 4 +- .../components/misc/panels/DockContainer.jsx | 20 ++++++++ js/extension/epics/setup.js | 47 +++++++++++++++---- js/extension/plugins/Extension.jsx | 13 +++++ js/extension/plugins/cadastrapp/Main.jsx | 34 +++++++++++--- js/extension/selectors/maplayout.js | 36 ++++++++++++++ 6 files changed, 135 insertions(+), 19 deletions(-) create mode 100644 js/extension/components/misc/panels/DockContainer.jsx create mode 100644 js/extension/selectors/maplayout.js diff --git a/js/extension/cadastrapp.css b/js/extension/cadastrapp.css index 939484d..97ea19d 100644 --- a/js/extension/cadastrapp.css +++ b/js/extension/cadastrapp.css @@ -10,8 +10,8 @@ overflow: hidden; top: 0; right: 0; - height: calc(100% - 30px); - width: 660px; + height: 100%; + width: 100%; z-index: 1000; } .cadastrapp .top { diff --git a/js/extension/components/misc/panels/DockContainer.jsx b/js/extension/components/misc/panels/DockContainer.jsx new file mode 100644 index 0000000..8472d07 --- /dev/null +++ b/js/extension/components/misc/panels/DockContainer.jsx @@ -0,0 +1,20 @@ +import React from 'react'; +import classnames from "classnames"; + +const DockContainer = ({ id, children, dockStyle, className, style = {}}) => { + const persistentStyle = { + width: `calc(100% - ${(dockStyle?.right ?? 0) + (dockStyle?.left ?? 0)}px)`, + transform: `translateX(-${(dockStyle?.right ?? 0)}px)`, + pointerEvents: 'none' + }; + return ( +
+ {children} +
+ ); +}; + +export default DockContainer; diff --git a/js/extension/epics/setup.js b/js/extension/epics/setup.js index 2442eeb..6979de7 100644 --- a/js/extension/epics/setup.js +++ b/js/extension/epics/setup.js @@ -4,7 +4,7 @@ import { wrapStartStop } from '@mapstore/observables/epics'; import { error } from '@mapstore/actions/notifications'; import { updateAdditionalLayer, removeAdditionalLayer } from '@mapstore/actions/additionallayers'; import { hideMapinfoMarker, toggleMapInfoState } from '@mapstore/actions/mapInfo'; -import { UPDATE_MAP_LAYOUT, updateMapLayout } from '../../../MapStore2/web/client/actions/maplayout'; +import { UPDATE_MAP_LAYOUT, updateMapLayout } from '@mapstore/actions/maplayout'; import { registerEventListener, unRegisterEventListener } from '@mapstore/actions/map'; import { cleanPopups } from '@mapstore/actions/mapPopups'; @@ -27,12 +27,16 @@ import { setConfiguration, setupCompleted, loading, - toggleSelectionTool + toggleSelectionTool, TOGGLE_SELECTION } from '../actions/cadastrapp'; import { SET_CONTROL_PROPERTIES, setControlProperty } from '@mapstore/actions/controls'; +import {coordinateEditorEnabledSelector} from "../../../selectors/annotations"; +import {SET_CONTROL_PROPERTY, TOGGLE_CONTROL} from "../../../actions/controls"; +import {findIndex, keys} from "lodash"; // size o -const OFFSET = 660; // size of cadastrapp. Maybe parametrize. Now in css + this constant +const OFFSET = 550; // size of cadastrapp. Maybe parametrize. Now in css + this constant +const shutdownList = ['metadataexplorer', 'measure', 'details', 'mapcatalog', 'maptemplates', 'userExtensions', 'annotations']; /** * utility function to check if the cadastrapp panel is open @@ -123,23 +127,46 @@ export const cadastrappMapLayout = (action$, store) => }) .map(({layout}) => { const action = updateMapLayout({ - layout, - right: OFFSET, + ...layout, + right: OFFSET + (layout?.right ?? 0), boundingMapRect: { ...(layout.boundingMapRect || {}), - right: OFFSET + right: OFFSET + (layout?.boundingMapRect?.right ?? 0) } }); return { ...action, source: 'cadastrapp' }; // add an argument to avoid infinite loop. }); + +export const cadastrappCloseAnnotationsOnOpen = (action$, store) => + action$.ofType(TOGGLE_SELECTION) + .filter(({ selectionType }) => !!selectionType + ) + .filter(() => coordinateEditorEnabledSelector(store.getState()) + ) + .map(() => { + return setControlProperty("annotations", "enabled", false); + }); + /** - * Auto-closes cadastrapp when catalog is open + * Auto-closes cadastrapp when one of the shutdown-trigger tools is open */ export const cadastrappAutoClose = (action$, store) => - action$.ofType(SET_CONTROL_PROPERTIES) + action$.ofType(SET_CONTROL_PROPERTIES, SET_CONTROL_PROPERTY, TOGGLE_CONTROL) .filter(() => isCadastrappOpen(store)) - .filter(({ control, properties }) => control === "metadataexplorer" && properties?.enabled) // open the catalog from TOC - .map( () => setControlProperty(CONTROL_NAME, "enabled", false)); + .filter(({control, property, properties = [], type}) => { + const state = store.getState(); + const controlState = state.controls[control].enabled; + switch (type) { + case SET_CONTROL_PROPERTY: + case TOGGLE_CONTROL: + return (property === 'enabled' || !property) && controlState && shutdownList.includes(control); + default: + return findIndex(keys(properties), prop => prop === 'enabled') > -1 && controlState && shutdownList.includes(control); + } + }) + .map( () => { + return setControlProperty(CONTROL_NAME, "enabled", false); + }); /** * Intercept cadastrapp close event. diff --git a/js/extension/plugins/Extension.jsx b/js/extension/plugins/Extension.jsx index ea2524d..2a83f2f 100644 --- a/js/extension/plugins/Extension.jsx +++ b/js/extension/plugins/Extension.jsx @@ -13,6 +13,7 @@ import { CONTROL_NAME } from '../constants'; import {setUp, tearDown} from '../actions/cadastrapp'; import cadastrapp from '../reducers/cadastrapp'; import * as epics from '../epics/cadastrapp'; +import {mapLayoutValuesSelector} from "@js/extension/selectors/maplayout"; const compose = (...functions) => args => functions.reduceRight((arg, fn) => fn(arg), args); @@ -20,6 +21,8 @@ const compose = (...functions) => args => functions.reduceRight((arg, fn) => fn( const Cadastrapp = compose( connect((state) => ({ enabled: state.controls && state.controls[CONTROL_NAME] && state.controls[CONTROL_NAME].enabled || false, + dockStyle: mapLayoutValuesSelector(state, { right: true, height: true}, true), + dockWidth: 550, withButton: false }), { open: () => toggleControl(CONTROL_NAME, "enabled", true), @@ -49,6 +52,16 @@ export default { doNotHide: true, action: toggleControl.bind(null, CONTROL_NAME, null), priority: 1 + }, + SidebarMenu: { + name: "cadastrapp", + icon: , + tooltip: "cadastrapp.title", + text: , + doNotHide: true, + action: toggleControl.bind(null, CONTROL_NAME, null), + priority: 1, + position: 1000 } } }; diff --git a/js/extension/plugins/cadastrapp/Main.jsx b/js/extension/plugins/cadastrapp/Main.jsx index 39f3ca2..8dcdb55 100644 --- a/js/extension/plugins/cadastrapp/Main.jsx +++ b/js/extension/plugins/cadastrapp/Main.jsx @@ -8,6 +8,9 @@ import Header from './Header'; import { CONTROL_NAME } from '../../constants'; import LandedProperty from './LandedProperty'; import {configurationSelector} from "@js/extension/selectors/cadastrapp"; +import DockPanel from "@mapstore/components/misc/panels/DockPanel"; +import ContainerDimensions from "react-container-dimensions"; +import DockContainer from "@js/extension/components/misc/panels/DockContainer"; /** * Main Container of Cadastrapp. @@ -16,14 +19,31 @@ import {configurationSelector} from "@js/extension/selectors/cadastrapp"; export default connect(state => ({ enabled: state.controls && state.controls[CONTROL_NAME] && state.controls[CONTROL_NAME].enabled || false, configuration: configurationSelector(state) -}))(function Main({ enabled, ...props }) { +}))(function Main({ enabled, dockStyle, dockWidth, ...props }) { if (!enabled) { return null; } - return (
-
- - - -
); + return ( + + + {({ width }) => ( 1 ? width : dockWidth} + position="right" + bsStyle="primary" + style={dockStyle}> +
+
+ + + +
+
)} +
+
+ ); }); diff --git a/js/extension/selectors/maplayout.js b/js/extension/selectors/maplayout.js new file mode 100644 index 0000000..5b44567 --- /dev/null +++ b/js/extension/selectors/maplayout.js @@ -0,0 +1,36 @@ +/** + * Retrieve only specific attribute from map layout + * @function + * @memberof selectors.mapLayout + * @param {object} state the state + * @param {object} attributes attributes to retrieve, bool {left: true} + * @param {boolean} isDock flag to use dock paddings instead of toolbar paddings + * @return {object} selected attributes of layout of the map + */ +import {mapLayoutSelector} from "@mapstore/selectors/maplayout"; +import {memoize} from "lodash"; + +/** + * Get map layout bounds left, top, bottom and right + * @function + * @memberof selectors.mapLayout + * @param {object} state the state + * @return {object} boundingMapRect {left, top, bottom, right} + */ +export const boundingSidebarRectSelector = (state) => state.maplayout && state.maplayout.boundingSidebarRect || {}; + +export const mapLayoutValuesSelector = memoize((state, attributes = {}, isDock = false) => { + const layout = mapLayoutSelector(state); + const boundingSidebarRect = boundingSidebarRectSelector(state); + return layout && Object.keys(layout).filter(key => + attributes[key]).reduce((a, key) => { + if (isDock) { + return ({...a, [key]: (boundingSidebarRect[key] ?? layout[key])}); + } + return ({...a, [key]: layout[key]}); + }, + {}) || {}; +}, (state, attributes, isDock) => + JSON.stringify(mapLayoutSelector(state)) + + JSON.stringify(boundingSidebarRectSelector(state)) + + JSON.stringify(attributes) + (isDock ? '_isDock' : '')); From f3369ffec78cc4caf4f9a0a6af63c0c8889395b0 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 2 May 2022 02:28:44 +0300 Subject: [PATCH 2/6] Minor fixes and priority change for BurgerMenu --- js/extension/epics/setup.js | 16 ++++++++-------- js/extension/plugins/Extension.jsx | 4 ++-- js/extension/selectors/maplayout.js | 29 +++++++++++------------------ 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/js/extension/epics/setup.js b/js/extension/epics/setup.js index 6979de7..dec4a5f 100644 --- a/js/extension/epics/setup.js +++ b/js/extension/epics/setup.js @@ -29,9 +29,9 @@ import { loading, toggleSelectionTool, TOGGLE_SELECTION } from '../actions/cadastrapp'; -import { SET_CONTROL_PROPERTIES, setControlProperty } from '@mapstore/actions/controls'; -import {coordinateEditorEnabledSelector} from "../../../selectors/annotations"; -import {SET_CONTROL_PROPERTY, TOGGLE_CONTROL} from "../../../actions/controls"; +import { SET_CONTROL_PROPERTIES, setControlProperty, + SET_CONTROL_PROPERTY, TOGGLE_CONTROL } from '@mapstore/actions/controls'; +import {coordinateEditorEnabledSelector} from "@mapstore/selectors/annotations"; import {findIndex, keys} from "lodash"; // size o @@ -157,11 +157,11 @@ export const cadastrappAutoClose = (action$, store) => const state = store.getState(); const controlState = state.controls[control].enabled; switch (type) { - case SET_CONTROL_PROPERTY: - case TOGGLE_CONTROL: - return (property === 'enabled' || !property) && controlState && shutdownList.includes(control); - default: - return findIndex(keys(properties), prop => prop === 'enabled') > -1 && controlState && shutdownList.includes(control); + case SET_CONTROL_PROPERTY: + case TOGGLE_CONTROL: + return (property === 'enabled' || !property) && controlState && shutdownList.includes(control); + default: + return findIndex(keys(properties), prop => prop === 'enabled') > -1 && controlState && shutdownList.includes(control); } }) .map( () => { diff --git a/js/extension/plugins/Extension.jsx b/js/extension/plugins/Extension.jsx index 2a83f2f..844cac0 100644 --- a/js/extension/plugins/Extension.jsx +++ b/js/extension/plugins/Extension.jsx @@ -1,6 +1,6 @@ import React from "react"; import { connect } from "react-redux"; -import { setControlProperty, toggleControl } from "@mapstore/actions/controls"; +import { toggleControl } from "@mapstore/actions/controls"; import {Glyphicon} from 'react-bootstrap'; import Message from "@mapstore/components/I18N/Message"; @@ -51,7 +51,7 @@ export default { icon: , doNotHide: true, action: toggleControl.bind(null, CONTROL_NAME, null), - priority: 1 + priority: 2 }, SidebarMenu: { name: "cadastrapp", diff --git a/js/extension/selectors/maplayout.js b/js/extension/selectors/maplayout.js index 5b44567..2cf3867 100644 --- a/js/extension/selectors/maplayout.js +++ b/js/extension/selectors/maplayout.js @@ -1,3 +1,8 @@ +import {mapLayoutSelector} from "@mapstore/selectors/maplayout"; +import {memoize} from "lodash"; + +export const boundingSidebarRectSelector = (state) => state.maplayout && state.maplayout.boundingSidebarRect || {}; + /** * Retrieve only specific attribute from map layout * @function @@ -7,29 +12,17 @@ * @param {boolean} isDock flag to use dock paddings instead of toolbar paddings * @return {object} selected attributes of layout of the map */ -import {mapLayoutSelector} from "@mapstore/selectors/maplayout"; -import {memoize} from "lodash"; - -/** - * Get map layout bounds left, top, bottom and right - * @function - * @memberof selectors.mapLayout - * @param {object} state the state - * @return {object} boundingMapRect {left, top, bottom, right} - */ -export const boundingSidebarRectSelector = (state) => state.maplayout && state.maplayout.boundingSidebarRect || {}; - export const mapLayoutValuesSelector = memoize((state, attributes = {}, isDock = false) => { const layout = mapLayoutSelector(state); const boundingSidebarRect = boundingSidebarRectSelector(state); return layout && Object.keys(layout).filter(key => attributes[key]).reduce((a, key) => { - if (isDock) { - return ({...a, [key]: (boundingSidebarRect[key] ?? layout[key])}); - } - return ({...a, [key]: layout[key]}); - }, - {}) || {}; + if (isDock) { + return ({...a, [key]: (boundingSidebarRect[key] ?? layout[key])}); + } + return ({...a, [key]: layout[key]}); + }, + {}) || {}; }, (state, attributes, isDock) => JSON.stringify(mapLayoutSelector(state)) + JSON.stringify(boundingSidebarRectSelector(state)) + From f2e85a945923eebc34f9f79dd415f500dd64613c Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 3 May 2022 23:18:17 +0300 Subject: [PATCH 3/6] Make cadastrapp write to layout.rightPanel property to make it's possible to track if cadastrapp panel is open. --- js/extension/epics/setup.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/extension/epics/setup.js b/js/extension/epics/setup.js index dec4a5f..f40e0e9 100644 --- a/js/extension/epics/setup.js +++ b/js/extension/epics/setup.js @@ -131,8 +131,9 @@ export const cadastrappMapLayout = (action$, store) => right: OFFSET + (layout?.right ?? 0), boundingMapRect: { ...(layout.boundingMapRect || {}), - right: OFFSET + (layout?.boundingMapRect?.right ?? 0) - } + right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0) + }, + rightPanel: true }); return { ...action, source: 'cadastrapp' }; // add an argument to avoid infinite loop. }); From 6047129ccf7238b625b7a7cbec09115cdb8dbf33 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 7 May 2022 00:31:05 +0300 Subject: [PATCH 4/6] - Fix of dependency for cadastrapp; - Making menu item toggleable; - Alternative set of actions for cadastrapp when tool should be toggled without affecting drawing status - Close feature editor when cadastrapp is open. - Reset annotation editing session when cadastrapp selection tool is activated. - Toggle cadastrapp tool off when annotation triggers drawing. --- assets/index.json | 2 +- js/extension/actions/cadastrapp.js | 6 ++- js/extension/epics/mapSelection.js | 15 +++++-- js/extension/epics/setup.js | 68 +++++++++++++++++++++++------- js/extension/plugins/Extension.jsx | 1 + 5 files changed, 69 insertions(+), 23 deletions(-) diff --git a/assets/index.json b/assets/index.json index fd1b6f5..4f4d86f 100644 --- a/assets/index.json +++ b/assets/index.json @@ -14,7 +14,7 @@ } }, "dependencies": [ - "BurgerMenu" + "SidebarMenu" ] } ] diff --git a/js/extension/actions/cadastrapp.js b/js/extension/actions/cadastrapp.js index e2d5f18..39f1211 100644 --- a/js/extension/actions/cadastrapp.js +++ b/js/extension/actions/cadastrapp.js @@ -109,10 +109,12 @@ export const tearDown = () => ({ /** * Toggles map selection in one of the modes available * @param {string} selectionType type of selection (constants.SELECTION_TYPES) + * @param {boolean} resetDraw should it reset draw status or not */ -export const toggleSelectionTool = (selectionType) => ({ +export const toggleSelectionTool = (selectionType, resetDraw = true) => ({ type: TOGGLE_SELECTION, - selectionType + selectionType, + resetDraw }); /** diff --git a/js/extension/epics/mapSelection.js b/js/extension/epics/mapSelection.js index e5b43bd..aace814 100644 --- a/js/extension/epics/mapSelection.js +++ b/js/extension/epics/mapSelection.js @@ -34,7 +34,7 @@ import { } from '../selectors/cadastrapp'; import { getLayerJSONFeature } from '@mapstore/observables/wfs'; import { wrapStartStop } from '@mapstore/observables/epics'; -import { MOUSE_MOVE, MOUSE_OUT, registerEventListener, unRegisterEventListener } from '@mapstore/actions/map'; +import {MOUSE_MOVE, MOUSE_OUT, unRegisterEventListener} from '@mapstore/actions/map'; import { addPopup, cleanPopups } from '@mapstore/actions/mapPopups'; import { mapSelector } from '@mapstore/selectors/map'; @@ -46,11 +46,18 @@ const CLEAN_ACTION = changeDrawingStatus("clean"); const DEACTIVATE_ACTIONS = [ CLEAN_ACTION, changeDrawingStatus("stop"), - registerEventListener(MOUSE_EVENT, CONTROL_NAME), + unRegisterEventListener(MOUSE_EVENT, CONTROL_NAME), loading(0, "plotSelection") // reset loading if stopped due to close ]; +export const ON_DRAW_DEACTIVATE_ACTIONS = [ + unRegisterEventListener(MOUSE_EVENT, CONTROL_NAME), + loading(0, "plotSelection") // reset loading if stopped due to close +]; + const deactivate = () => Rx.Observable.from(DEACTIVATE_ACTIONS); +export const deactivateOnAnotherDraw = () => Rx.Observable.from(ON_DRAW_DEACTIVATE_ACTIONS); + /** * Extract the drawMethod for DrawSupport from the method * @param {string} selection the current tool selected @@ -123,7 +130,7 @@ const getGeometry = point => { * Handle map selection tools and events */ export const cadastrappMapSelection = (action$, {getState = () => {}}) => - action$.ofType(TOGGLE_SELECTION).switchMap(({selectionType}) => { + action$.ofType(TOGGLE_SELECTION).switchMap(({selectionType, resetDraw}) => { if (selectionType) { const startDrawingAction = changeDrawingStatus('start', drawMethod(selectionType), 'cadastrapp', [], { stopAfterDrawing: true }); return action$.ofType(END_DRAWING).flatMap( @@ -178,7 +185,7 @@ export const cadastrappMapSelection = (action$, {getState = () => {}}) => .concat(deactivate()); // on close, deactivate any draw session remaining } // if the selection type is not present, it means has been reset, so deactivate any drawing tool - return deactivate(); + return !resetDraw ? deactivateOnAnotherDraw() : deactivate(); }); /** * Retrieves the geometry of the ufFeature, when not present, and shows the LandedPropertyInformation with this data. diff --git a/js/extension/epics/setup.js b/js/extension/epics/setup.js index f40e0e9..6aa40ac 100644 --- a/js/extension/epics/setup.js +++ b/js/extension/epics/setup.js @@ -18,8 +18,7 @@ import { } from '../constants'; import { getConfiguration } from '../api'; -import get from 'lodash/get'; -import { configurationSelector } from '../selectors/cadastrapp'; +import {findIndex, keys, get} from "lodash"; import { SETUP, @@ -29,14 +28,22 @@ import { loading, toggleSelectionTool, TOGGLE_SELECTION } from '../actions/cadastrapp'; -import { SET_CONTROL_PROPERTIES, setControlProperty, - SET_CONTROL_PROPERTY, TOGGLE_CONTROL } from '@mapstore/actions/controls'; +import { + SET_CONTROL_PROPERTIES, + SET_CONTROL_PROPERTY, + TOGGLE_CONTROL, + setControlProperty +} from '@mapstore/actions/controls'; +import {closeFeatureGrid, OPEN_FEATURE_GRID} from "@mapstore/actions/featuregrid"; +import {resetCoordEditor, START_DRAWING} from "@mapstore/actions/annotations"; +import {configurationSelector, currentSelectionToolSelector} from '../selectors/cadastrapp'; +import {isFeatureGridOpen} from "@mapstore/selectors/featuregrid"; import {coordinateEditorEnabledSelector} from "@mapstore/selectors/annotations"; -import {findIndex, keys} from "lodash"; +import {CHANGE_DRAWING_STATUS} from "@mapstore/actions/draw"; // size o const OFFSET = 550; // size of cadastrapp. Maybe parametrize. Now in css + this constant -const shutdownList = ['metadataexplorer', 'measure', 'details', 'mapcatalog', 'maptemplates', 'userExtensions', 'annotations']; +const shutdownList = ['metadataexplorer', 'measure', 'details', 'mapcatalog', 'maptemplates', 'userExtensions', 'FeatureEditor']; /** * utility function to check if the cadastrapp panel is open @@ -58,7 +65,8 @@ export const cadastrappSetup = (action$, store) => let initStream$ = Rx.Observable.defer(() => getConfiguration()) .switchMap(data => { return Rx.Observable.of(setConfiguration(data)); - }); + }) + .startWith(...(isFeatureGridOpen ? [closeFeatureGrid()] : [])); const mapInfoEnabled = get(store.getState(), "mapInfo.enabled"); return initStream$.concat( Rx.Observable.defer(() => { @@ -138,14 +146,12 @@ export const cadastrappMapLayout = (action$, store) => return { ...action, source: 'cadastrapp' }; // add an argument to avoid infinite loop. }); -export const cadastrappCloseAnnotationsOnOpen = (action$, store) => +export const cadastrappCloseAnnotationsOnToolToggledOn = (action$, store) => action$.ofType(TOGGLE_SELECTION) - .filter(({ selectionType }) => !!selectionType - ) - .filter(() => coordinateEditorEnabledSelector(store.getState()) + .filter(({ selectionType }) => !!selectionType && coordinateEditorEnabledSelector(store.getState()) ) .map(() => { - return setControlProperty("annotations", "enabled", false); + return resetCoordEditor(); }); /** @@ -169,16 +175,46 @@ export const cadastrappAutoClose = (action$, store) => return setControlProperty(CONTROL_NAME, "enabled", false); }); +export const closeCadastrappOnFeatureGridOpen = (action$) => + action$.ofType(OPEN_FEATURE_GRID) + .switchMap( () => { + let actions = [ + setControlProperty('cadastrapp', 'enabled', false) + ]; + return Rx.Observable.from(actions); + }); + +export const toggleCadastrapToolOnAnnotationsDrawing = (action$, store) => + action$.ofType(START_DRAWING, CHANGE_DRAWING_STATUS) + .filter(({type, status, owner}) => { + const currentSelectionTool = currentSelectionToolSelector(store.getState()); + switch (type) { + case CHANGE_DRAWING_STATUS: + return !!currentSelectionTool && status === 'drawOrEdit' && owner === 'annotations'; + case START_DRAWING: + default: + return !!currentSelectionTool; + } + }) + .switchMap( () => { + let actions = [ + toggleSelectionTool(null, false) + ]; + return Rx.Observable.from(actions); + }); + /** * Intercept cadastrapp close event. * - Removes the cadastre layer from the map */ export const cadastrappTearDown = (action$, {getState = ()=>{}}) => - action$.ofType(TEAR_DOWN).switchMap(() => - Rx.Observable.from([ - toggleSelectionTool(), + action$.ofType(TEAR_DOWN).switchMap(() => { + const cadastrappIsDrawOwner = get(getState(), 'draw.drawOwner', false) === 'cadastrapp'; + return Rx.Observable.from([ + toggleSelectionTool(null, cadastrappIsDrawOwner), removeAdditionalLayer({id: CADASTRAPP_RASTER_LAYER_ID, owner: CADASTRAPP_OWNER}), removeAdditionalLayer({id: CADASTRAPP_VECTOR_LAYER_ID, owner: CADASTRAPP_OWNER}), cleanPopups(), unRegisterEventListener(MOUSE_EVENT, CONTROL_NAME) // Reset map's mouse event trigger - ]).concat([...(!get(getState(), "mapInfo.enabled") ? [toggleMapInfoState()] : [])])); + ]).concat([...(!get(getState(), "mapInfo.enabled") ? [toggleMapInfoState()] : [])]); + }); diff --git a/js/extension/plugins/Extension.jsx b/js/extension/plugins/Extension.jsx index 844cac0..05beae2 100644 --- a/js/extension/plugins/Extension.jsx +++ b/js/extension/plugins/Extension.jsx @@ -60,6 +60,7 @@ export default { text: , doNotHide: true, action: toggleControl.bind(null, CONTROL_NAME, null), + toggle: true, priority: 1, position: 1000 } From 0cc75e10fe4159323a0cb8c1c00b4f29dfb7769e Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 7 May 2022 00:39:30 +0300 Subject: [PATCH 5/6] Function documentation --- .../components/misc/panels/DockContainer.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/extension/components/misc/panels/DockContainer.jsx b/js/extension/components/misc/panels/DockContainer.jsx index 8472d07..bc14197 100644 --- a/js/extension/components/misc/panels/DockContainer.jsx +++ b/js/extension/components/misc/panels/DockContainer.jsx @@ -1,6 +1,19 @@ import React from 'react'; import classnames from "classnames"; +/** + * Wrapper for DockablePanel with main intension to support applying of custom styling to make dock panels have proper + * offset depending on the sidebars presence on the page + * @memberof components.misc.panels + * @name DockContainer + * @param id {string} - id applied to the container + * @param children {JSX.Element} + * @param dockStyle {object} - style object obtained from mapLayoutValuesSelector and used to calculate offsets + * @param className {string} - class name + * @param style - style object to apply to the container. Can be used to overwrite styles applied by dockStyle calculations + * @returns {JSX.Element} + * @constructor + */ const DockContainer = ({ id, children, dockStyle, className, style = {}}) => { const persistentStyle = { width: `calc(100% - ${(dockStyle?.right ?? 0) + (dockStyle?.left ?? 0)}px)`, From 789ba0bcdb35b888890f7cf0c651b828fbd8132d Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 10 May 2022 14:05:22 +0300 Subject: [PATCH 6/6] Merging epics into one. --- js/extension/epics/setup.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/js/extension/epics/setup.js b/js/extension/epics/setup.js index 6aa40ac..d43a298 100644 --- a/js/extension/epics/setup.js +++ b/js/extension/epics/setup.js @@ -155,15 +155,17 @@ export const cadastrappCloseAnnotationsOnToolToggledOn = (action$, store) => }); /** - * Auto-closes cadastrapp when one of the shutdown-trigger tools is open + * Auto-closes cadastrapp when one of the shutdown-trigger tools is open or when Feature editor is open */ export const cadastrappAutoClose = (action$, store) => - action$.ofType(SET_CONTROL_PROPERTIES, SET_CONTROL_PROPERTY, TOGGLE_CONTROL) + action$.ofType(SET_CONTROL_PROPERTIES, SET_CONTROL_PROPERTY, TOGGLE_CONTROL, OPEN_FEATURE_GRID) .filter(() => isCadastrappOpen(store)) .filter(({control, property, properties = [], type}) => { const state = store.getState(); - const controlState = state.controls[control].enabled; + const controlState = state.controls[control]?.enabled; switch (type) { + case OPEN_FEATURE_GRID: + return true; case SET_CONTROL_PROPERTY: case TOGGLE_CONTROL: return (property === 'enabled' || !property) && controlState && shutdownList.includes(control); @@ -175,15 +177,6 @@ export const cadastrappAutoClose = (action$, store) => return setControlProperty(CONTROL_NAME, "enabled", false); }); -export const closeCadastrappOnFeatureGridOpen = (action$) => - action$.ofType(OPEN_FEATURE_GRID) - .switchMap( () => { - let actions = [ - setControlProperty('cadastrapp', 'enabled', false) - ]; - return Rx.Observable.from(actions); - }); - export const toggleCadastrapToolOnAnnotationsDrawing = (action$, store) => action$.ofType(START_DRAWING, CHANGE_DRAWING_STATUS) .filter(({type, status, owner}) => {