Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2665 Add an action to force resize of Map component #2666

Merged
merged 2 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion web/client/actions/__tests__/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var {
UPDATE_VERSION,
INIT_MAP,
ZOOM_TO_EXTENT,
RESIZE_MAP,
creationError,
changeMapView,
clickOnMap,
Expand All @@ -31,7 +32,8 @@ var {
changeRotation,
updateVersion,
initMap,
zoomToExtent
zoomToExtent,
resizeMap
} = require('../map');

describe('Test correctness of the map actions', () => {
Expand Down Expand Up @@ -151,4 +153,10 @@ describe('Test correctness of the map actions', () => {
expect(retval).toExist();
expect(retval.type).toEqual(INIT_MAP);
});

it('resizeMap', () => {
const retval = resizeMap();
expect(retval).toExist();
expect(retval.type).toEqual(RESIZE_MAP);
});
});
11 changes: 10 additions & 1 deletion web/client/actions/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const CHANGE_ROTATION = 'CHANGE_ROTATION';
const CREATION_ERROR_LAYER = 'CREATION_ERROR_LAYER';
const UPDATE_VERSION = 'UPDATE_VERSION';
const INIT_MAP = 'INIT_MAP';
const RESIZE_MAP = 'RESIZE_MAP';

function creationError(options) {
return {
Expand Down Expand Up @@ -130,6 +131,12 @@ function initMap() {
};
}

function resizeMap() {
return {
type: RESIZE_MAP
};
}

module.exports = {
CHANGE_MAP_VIEW,
CLICK_ON_MAP,
Expand All @@ -145,6 +152,7 @@ module.exports = {
CREATION_ERROR_LAYER,
UPDATE_VERSION,
INIT_MAP,
RESIZE_MAP,
changeMapView,
clickOnMap,
changeMousePointer,
Expand All @@ -158,5 +166,6 @@ module.exports = {
zoomToPoint,
creationError,
updateVersion,
initMap
initMap,
resizeMap
};
8 changes: 8 additions & 0 deletions web/client/reducers/__tests__/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,12 @@ describe('Test the map reducer', () => {
let state = mapConfig({}, action);
expect(state.version).toEqual(version);
});

it('force resize update of map', () => {
const action = {
type: 'RESIZE_MAP'
};
let state = mapConfig({}, action);
expect(state.rersize).toEqual(1);
});
});
5 changes: 4 additions & 1 deletion web/client/reducers/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

var {CHANGE_MAP_VIEW, CHANGE_MOUSE_POINTER,
CHANGE_ZOOM_LVL, CHANGE_MAP_CRS, CHANGE_MAP_SCALES, ZOOM_TO_EXTENT, PAN_TO,
CHANGE_MAP_STYLE, CHANGE_ROTATION, UPDATE_VERSION, ZOOM_TO_POINT} = require('../actions/map');
CHANGE_MAP_STYLE, CHANGE_ROTATION, UPDATE_VERSION, ZOOM_TO_POINT, RESIZE_MAP} = require('../actions/map');
const {isArray} = require('lodash');


Expand Down Expand Up @@ -133,6 +133,9 @@ function mapConfig(state = null, action) {
case CHANGE_MAP_STYLE: {
return assign({}, state, {mapStateSource: action.mapStateSource, style: action.style, resize: state.resize ? state.resize + 1 : 1});
}
case RESIZE_MAP: {
return assign({}, state, {resize: state.resize ? state.resize + 1 : 1});
}
case CHANGE_ROTATION: {
let newBbox = assign({}, state.bbox, {rotation: action.rotation});
return assign({}, state, {bbox: newBbox, mapStateSource: action.mapStateSource});
Expand Down