Skip to content

Commit

Permalink
Fix geosolutions-it#3852 Annotation do not work without setting initi…
Browse files Browse the repository at this point in the history
…al state

It turned out the annotation plugin cannot draw on the map when
the default configuration is not provided. This commit fix and allow
annotation to work well without default config.
  • Loading branch information
kasongoyo committed Aug 8, 2019
1 parent e470657 commit 61ccb36
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion web/client/epics/__tests__/annotations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {set} = require('../../utils/ImmutableUtils');
const {HIDE_MAPINFO_MARKER, PURGE_MAPINFO_RESULTS, purgeMapInfoResults} = require('../../actions/mapInfo');
const {configureMap} = require('../../actions/config');
const {CLOSE_IDENTIFY} = require('../../actions/mapInfo');
const {editAnnotation, confirmRemoveAnnotation, saveAnnotation, cancelEditAnnotation,
const {editAnnotation, confirmRemoveAnnotation, saveAnnotation, startDrawing, cancelEditAnnotation,
setStyle, highlight, cleanHighlight, download, loadAnnotations, SET_STYLE, toggleStyle,
resetCoordEditor, changeRadius, changeText, changeSelected, confirmDeleteFeature, openEditor, SHOW_ANNOTATION
} = require('../../actions/annotations');
Expand Down Expand Up @@ -856,4 +856,24 @@ describe('annotations Epics', () => {
store.dispatch(action);
});

it('should safely start drawing annotation when no annotation config provided', (done) => {
store = mockStore({
annotations: {
editing: {
features: [{}]
}
}
});

store.subscribe(() => {
const actions = store.getActions();
if (actions.length >= 2) {
expect(actions[1].type).toBe(CHANGE_DRAWING_STATUS);
done();
}
});
const action = startDrawing();
store.dispatch(action);
});

});
3 changes: 2 additions & 1 deletion web/client/epics/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

const Rx = require('rxjs');
const {saveAs} = require('file-saver');
const {get} = require('lodash');
const {MAP_CONFIG_LOADED} = require('../actions/config');
const {TOGGLE_CONTROL, toggleControl, setControlProperty} = require('../actions/controls');
const {addLayer, updateNode, changeLayerProperties, removeLayer} = require('../actions/layers');
Expand Down Expand Up @@ -320,7 +321,7 @@ module.exports = (viewer) => ({
const feature = state.annotations.editing;
const type = state.annotations.featureType;
const defaultTextAnnotation = state.annotations.defaultTextAnnotation;
const multiGeom = state.annotations.config.multiGeometry;
const multiGeom = get(state, 'annotations.config.multiGeometry');
const drawOptions = {
featureProjection: "EPSG:4326",
stopAfterDrawing: !multiGeom,
Expand Down

0 comments on commit 61ccb36

Please sign in to comment.