Skip to content

Commit 1487118

Browse files
author
kappu
committed
Readded the plugin btn to toolbar
1 parent 888c007 commit 1487118

6 files changed

Lines changed: 52 additions & 10 deletions

File tree

web/client/actions/__tests__/mapInfo-test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ var {
1818
SHOW_REVERSE_GEOCODE,
1919
HIDE_REVERSE_GEOCODE,
2020
GET_VECTOR_INFO,
21+
TOGGLE_MAPINFO_STATE,
2122
getFeatureInfo,
2223
changeMapInfoState,
2324
newMapInfoRequest,
2425
purgeMapInfoResults,
2526
changeMapInfoFormat,
2627
showMapinfoRevGeocode,
2728
hideMapinfoRevGeocode,
28-
getVectorInfo
29+
getVectorInfo,
30+
toggleMapInfoState
2931
} = require('../mapInfo');
3032

3133
describe('Test correctness of the map actions', () => {
@@ -191,4 +193,9 @@ describe('Test correctness of the map actions', () => {
191193
expect(e).toExist();
192194
expect(e.type).toBe(HIDE_REVERSE_GEOCODE);
193195
});
196+
197+
it('toggle map info state', () => {
198+
const retval = toggleMapInfoState();
199+
expect(retval.type).toBe(TOGGLE_MAPINFO_STATE);
200+
});
194201
});

web/client/actions/mapInfo.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const GET_VECTOR_INFO = 'GET_VECTOR_INFO';
2626
const NO_QUERYABLE_LAYERS = 'NO_QUERYABLE_LAYERS';
2727
const CLEAR_WARNING = 'CLEAR_WARNING';
2828
const FEATURE_INFO_CLICK = 'FEATURE_INFO_CLICK';
29+
const TOGGLE_MAPINFO_STATE = 'TOGGLE_MAPINFO_STATE';
2930

3031
/**
3132
* Private
@@ -189,6 +190,12 @@ function hideMapinfoRevGeocode() {
189190
};
190191
}
191192

193+
function toggleMapInfoState() {
194+
return {
195+
type: TOGGLE_MAPINFO_STATE
196+
};
197+
}
198+
192199
module.exports = {
193200
ERROR_FEATURE_INFO,
194201
EXCEPTIONS_FEATURE_INFO,
@@ -205,6 +212,7 @@ module.exports = {
205212
NO_QUERYABLE_LAYERS,
206213
CLEAR_WARNING,
207214
FEATURE_INFO_CLICK,
215+
TOGGLE_MAPINFO_STATE,
208216
getFeatureInfo,
209217
changeMapInfoState,
210218
newMapInfoRequest,
@@ -219,5 +227,6 @@ module.exports = {
219227
noQueryableLayers,
220228
clearWarning,
221229
errorFeatureInfo,
222-
loadFeatureInfo
230+
loadFeatureInfo,
231+
toggleMapInfoState
223232
};

web/client/localConfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@
203203
},
204204
"override": {
205205
"Toolbar": {
206-
"position": 11,
207-
"alwaysVisible": true
206+
"position": 11
208207
}
209208
}
210209
},

web/client/plugins/Identify.jsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
*/
88
const React = require('react');
99

10+
const {Glyphicon} = require('react-bootstrap');
11+
1012
const {connect} = require('react-redux');
1113
const {createSelector} = require('reselect');
1214

1315
const {mapSelector} = require('../selectors/map');
1416
const {layersSelector} = require('../selectors/layers');
1517
const {on} = require('../actions/controls');
1618

17-
const {getFeatureInfo, getVectorInfo, purgeMapInfoResults, showMapinfoMarker, hideMapinfoMarker, showMapinfoRevGeocode, hideMapinfoRevGeocode, noQueryableLayers, clearWarning} = require('../actions/mapInfo');
19+
const {getFeatureInfo, getVectorInfo, purgeMapInfoResults, showMapinfoMarker, hideMapinfoMarker, showMapinfoRevGeocode, hideMapinfoRevGeocode, noQueryableLayers, clearWarning, toggleMapInfoState} = require('../actions/mapInfo');
1820
const {closeAnnotations} = require('../actions/annotations');
1921
const {changeMousePointer} = require('../actions/map');
2022
const {changeMapInfoFormat} = require('../actions/mapInfo');
@@ -53,10 +55,12 @@ const conditionalToggle = on.bind(null, purgeMapInfoResults(), (state) =>
5355
* Identify plugin. This plugin allows to perform getfeature info.
5456
* It can be configured to have a mobile or a desktop flavor.
5557
* It's enabled by default. The bubbling of an on_click_map action to GFI is stopped
56-
* if Annotations orFeatureGrid plugins are editing, draw or measurement supports are
57-
* active ore the identify plugin is disabled.
58-
* To restore old behaviour, in mapInfo state, set enabled to false and disabledAlwaysOn to true and
59-
* manage the plugin using changeMapInfoState action or toggleControl action with 'info' as control name.
58+
* if Annotations or FeatureGrid plugins are editing, draw or measurement supports are
59+
* active, the query panel is active or the identify plugin is disabled.
60+
* To restore old behaviour, in mapInfo state, set disabledAlwaysOn to true and
61+
* manage the plugin using toggleControl action with 'info' as control name.
62+
* It's possible also possible disable the plugin by changeMapInfoState or toggleMapInfoState actions
63+
*
6064
* @class Identify
6165
* @memberof plugins
6266
* @static
@@ -117,6 +121,18 @@ const FeatureInfoFormatSelector = connect((state) => ({
117121

118122
module.exports = {
119123
IdentifyPlugin: assign(IdentifyPlugin, {
124+
Toolbar: {
125+
name: 'info',
126+
position: 6,
127+
tooltip: "info.tooltip",
128+
icon: <Glyphicon glyph="map-marker"/>,
129+
help: <Message msgId="helptexts.infoButton"/>,
130+
action: toggleMapInfoState,
131+
selector: (state) => ({
132+
bsStyle: state.mapInfo && state.mapInfo.enabled ? "success" : "primary",
133+
active: !!(state.mapInfo && state.mapInfo.enabled)
134+
})
135+
},
120136
Settings: {
121137
tool: <FeatureInfoFormatSelector
122138
key="featureinfoformat"

web/client/reducers/__tests__/mapInfo-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,10 @@ describe('Test the mapInfo reducer', () => {
246246
expect(state.showMarker).toBe(false);
247247
});
248248

249+
it('should toggle mapinfo state', () => {
250+
let state = mapInfo({enabled: true}, {type: 'TOGGLE_MAPINFO_STATE'});
251+
expect(state).toExist();
252+
expect(state.enabled).toBe(false);
253+
});
254+
249255
});

web/client/reducers/mapInfo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const {
2121
GET_VECTOR_INFO,
2222
NO_QUERYABLE_LAYERS,
2323
CLEAR_WARNING,
24-
FEATURE_INFO_CLICK
24+
FEATURE_INFO_CLICK,
25+
TOGGLE_MAPINFO_STATE
2526
} = require('../actions/mapInfo');
2627

2728
const {RESET_CONTROLS} = require('../actions/controls');
@@ -59,6 +60,10 @@ function mapInfo(state = initState, action) {
5960
return assign({}, state, {
6061
enabled: action.enabled
6162
});
63+
case TOGGLE_MAPINFO_STATE:
64+
return assign({}, state, {
65+
enabled: !state.enabled
66+
});
6267
case NEW_MAPINFO_REQUEST: {
6368
const {reqId, request} = action;
6469
const requests = state.requests || [];

0 commit comments

Comments
 (0)