Skip to content

Commit

Permalink
add settings inside the annotation layer panel
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Sep 8, 2023
1 parent bef0fc6 commit b17e6a1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
4 changes: 2 additions & 2 deletions web/client/epics/measurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
mergeAnnotationsFeatures
} from '../plugins/Annotations/actions/annotations';
import {updateDockPanelsList} from "../actions/maplayout";
import { selectedAnnotationLayer } from '../plugins/Annotations/selectors/annotations';
import { getSelectedAnnotationLayer } from '../plugins/Annotations/selectors/annotations';
import {shutdownToolOnAnotherToolDrawing} from "../utils/ControlUtils";
import { ANNOTATIONS } from '../plugins/Annotations/utils/AnnotationsUtils';

Expand All @@ -50,7 +50,7 @@ export const addAnnotationFromMeasureEpic = (action$, store) =>
const { id = uuidv1(), visibility = true } = properties || {};
const annotation = convertMeasuresToAnnotation(features, textLabels, uom, id, 'Annotations created from measurements');
const state = store.getState();
const selected = selectedAnnotationLayer(state);
const selected = getSelectedAnnotationLayer(state);
const commonActions = [
changeMeasurement(null),
changeMeasurement('LineString')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
selectAnnotationFeature
} from '../actions/annotations';
import {
selectedAnnotationLayer,
getSelectedAnnotationLayer,
getAnnotationsSession,
getSelectedAnnotationFeatureId
} from '../selectors/annotations';
Expand Down Expand Up @@ -384,7 +384,7 @@ function AnnotationsEditor({
const ConnectedAnnotationsEditor = connect(
createSelector([
createControlVariableSelector(ANNOTATIONS, 'ready'),
selectedAnnotationLayer,
getSelectedAnnotationLayer,
mapSelector,
is3DMode,
getAnnotationsSession,
Expand Down
35 changes: 29 additions & 6 deletions web/client/plugins/Annotations/containers/AnnotationsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


import React, { useEffect, useState } from 'react';
import { Nav, NavItem, Glyphicon, ButtonGroup, Alert } from "react-bootstrap";
import { Nav, NavItem, Glyphicon, ButtonGroup, Alert, ControlLabel } from "react-bootstrap";
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import isFunction from 'lodash/isFunction';
Expand All @@ -25,7 +25,7 @@ import {
editAnnotation,
removeAnnotation
} from '../actions/annotations';
import { selectedAnnotationLayer } from '../selectors/annotations';
import { getSelectedAnnotationLayer } from '../selectors/annotations';
import { createControlEnabledSelector } from '../../../selectors/controls';
import { mapLayoutValuesSelector } from '../../../selectors/maplayout';
import { setControlProperty } from '../../../actions/controls';
Expand All @@ -35,6 +35,7 @@ import { DEFAULT_TARGET_ID } from '../constants';
import ConfirmDialog from '../../../components/misc/ConfirmDialog';
import Portal from '../../../components/misc/Portal';
import { mapSelector } from '../../../selectors/map';
import VisibilityLimitsForm from '../../../components/TOC/fragments/settings/VisibilityLimitsForm';

const Button = tooltip(MSButton);

Expand Down Expand Up @@ -141,7 +142,10 @@ function AnnotationsPanel({
],
closeId,
onCancel = () => {},
activeClickEventListener
activeClickEventListener,
projection,
resolutions,
zoom
}) {
const properties = {
title: selected?.title,
Expand Down Expand Up @@ -236,6 +240,12 @@ function AnnotationsPanel({
{' '}
<Glyphicon glyph={validateFeatures() ? 'ok-sign text-success' : 'exclamation-mark text-danger'}/>
</NavItem>
<NavItem
key="geometries"
eventKey="settings"
onClick={() => setTab('settings')}>
<Message msgId="settings"/>
</NavItem>
<Button
className="square-button-md"
bsStyle="primary"
Expand All @@ -247,7 +257,7 @@ function AnnotationsPanel({
</Button>
</Nav>
<div className="ms-annotations-panel-body">
<div className="ms-annotations-properties" style={tab === 'properties' ? { } : { display: 'none' }}>
<div className="ms-annotations-panel-content" style={tab === 'properties' ? { } : { display: 'none' }}>
<AnnotationsFields
fields={fields}
properties={properties}
Expand All @@ -266,6 +276,16 @@ function AnnotationsPanel({
</div>
<div id={targetId} style={tab === 'geometries' ? {} : { display: 'none' }} >
</div>
<div className="ms-annotations-panel-content" style={tab === 'settings' ? { } : { display: 'none' }}>
<VisibilityLimitsForm
title={<ControlLabel><Message msgId="layerProperties.visibilityLimits.title"/></ControlLabel>}
layer={selected}
onChange={(options) => onChange(selected.id, 'layers', options)}
projection={projection}
resolutions={resolutions}
zoom={zoom}
/>
</div>
</div>
{activeClickEventListener && <Alert bsStyle="warning">
<Message msgId="annotations.deactivatedMapInteraction" msgParams={{ pluginName: capitalize(activeClickEventListener) }}/>
Expand All @@ -291,14 +311,17 @@ const ConnectedAnnotationsPanel = connect(
createSelector([
createControlEnabledSelector(ANNOTATIONS),
state => mapLayoutValuesSelector(state, { height: true }),
selectedAnnotationLayer,
getSelectedAnnotationLayer,
mapSelector
],
(enabled, style, selected, map) => ({
enabled,
style,
selected: enabled ? selected : null,
activeClickEventListener: map?.eventListeners?.click?.[0]
activeClickEventListener: map?.eventListeners?.click?.[0],
projection: map?.projection,
zoom: map?.zoom,
resolutions: map?.resolutions
})),
{
onClose: confirmCloseAnnotations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import expect from 'expect';
import {
annotationsLayerSelector,
annotationsLayersSelector,
selectedAnnotationLayer,
getSelectedAnnotationLayer,
editingSelector,
getAnnotationsSession,
getSelectedAnnotationFeatureId
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('annotations selectors', () => {
}
]);
});
it('selectedAnnotationLayer', () => {
it('getSelectedAnnotationLayer', () => {
const state = {
layers: {
flat: [
Expand All @@ -111,7 +111,7 @@ describe('annotations selectors', () => {
selected: ['annotations:1']
}
};
expect(selectedAnnotationLayer(state)).toEqual({
expect(getSelectedAnnotationLayer(state)).toEqual({
id: 'annotations:1',
type: 'vector',
title: 'Annotations',
Expand Down
2 changes: 1 addition & 1 deletion web/client/plugins/Annotations/selectors/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const annotationsLayersSelector = createSelector(
[layersSelector],
(layers) => layers.filter(isAnnotationLayer)
);
export const selectedAnnotationLayer = (state) => {
export const getSelectedAnnotationLayer = (state) => {
const selectedLayer = getSelectedLayer(state);
return selectedLayer && isAnnotationLayer(selectedLayer) ? selectedLayer : null;
};
Expand Down
18 changes: 12 additions & 6 deletions web/client/plugins/TOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { openQueryBuilder } from '../actions/layerFilter';
import { getLayerCapabilities } from '../actions/layerCapabilities';
import { zoomToExtent } from '../actions/map';
import { error } from '../actions/notifications';

import { getSelectedAnnotationLayer } from './Annotations/selectors/annotations';
import {
groupsSelector,
layersSelector,
Expand Down Expand Up @@ -112,7 +112,8 @@ const tocSelector = createShallowSelectorCreator(isEqual)(
isCesium,
userSelector,
isLocalizedLayerStylesEnabledSelector,
(enabled, groups, settings, swipeSettings, layerMetadata, layerdownload, map, currentLocale, currentLocaleLanguage, selectedNodes, filterText, layers, mapName, catalogActive, activateWidgetTool, generalInfoFormat, isCesiumActive, user, isLocalizedLayerStylesEnabled) => ({
getSelectedAnnotationLayer,
(enabled, groups, settings, swipeSettings, layerMetadata, layerdownload, map, currentLocale, currentLocaleLanguage, selectedNodes, filterText, layers, mapName, catalogActive, activateWidgetTool, generalInfoFormat, isCesiumActive, user, isLocalizedLayerStylesEnabled, selectedAnnotationLayer) => ({
enabled,
groups,
settings,
Expand Down Expand Up @@ -160,7 +161,8 @@ const tocSelector = createShallowSelectorCreator(isEqual)(
catalogActive,
activateWidgetTool,
user,
isLocalizedLayerStylesEnabled
isLocalizedLayerStylesEnabled,
selectedAnnotationLayer
})
);

Expand Down Expand Up @@ -603,7 +605,8 @@ const checkPluginsEnhancer = branch(
"activateLayerFilterTool",
"activateSettingsTool",
"FeatureEditor",
"activateLayerInfoTool"
"activateLayerInfoTool",
"selectedAnnotationLayer"
],
({
items = [],
Expand All @@ -614,11 +617,14 @@ const checkPluginsEnhancer = branch(
activateLayerFilterTool = true,
activateWidgetTool = true,
activateLayerInfoTool = true,
activateDownloadTool = true
activateDownloadTool = true,
// TODO: we should extract the toolbar button that could be injected (eg. TOCItemsSettings)
// in this way the logic could be moved in that plugin instead
selectedAnnotationLayer
}) => ({
activateAddLayerButton: activateAddLayerButton && !!find(items, { name: "MetadataExplorer" }) || false, // requires MetadataExplorer (Catalog)
activateAddGroupButton: activateAddGroupButton && !!find(items, { name: "AddGroup" }) || false,
activateSettingsTool: activateSettingsTool && !!find(items, { name: "TOCItemsSettings"}) || false,
activateSettingsTool: activateSettingsTool && !selectedAnnotationLayer && !!find(items, { name: "TOCItemsSettings"}) || false,
activateQueryTool: activateQueryTool && !!find(items, {name: "FeatureEditor"}) || false,
activateLayerFilterTool: activateLayerFilterTool && !!find(items, {name: "FilterLayer"}) || false,
// NOTE: activateWidgetTool is already controlled by a selector. TODO: Simplify investigating on the best approach
Expand Down
2 changes: 1 addition & 1 deletion web/client/themes/default/less/annotations.less
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
.ms-annotations-panel-body {
flex: 1;
position: relative;
.ms-annotations-properties {
.ms-annotations-panel-content {
position: absolute;
width: 100%;
height: 100%;
Expand Down

0 comments on commit b17e6a1

Please sign in to comment.