Skip to content

Commit f448fbf

Browse files
authored
Fixes #1686: warning when no queryable layer is available during identify click (#1700)
1 parent b41c97a commit f448fbf

File tree

9 files changed

+97
-9
lines changed

9 files changed

+97
-9
lines changed

web/client/actions/mapInfo.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const HIDE_MAPINFO_MARKER = 'HIDE_MAPINFO_MARKER';
2323
const SHOW_REVERSE_GEOCODE = 'SHOW_REVERSE_GEOCODE';
2424
const HIDE_REVERSE_GEOCODE = 'HIDE_REVERSE_GEOCODE';
2525
const GET_VECTOR_INFO = 'GET_VECTOR_INFO';
26+
const NO_QUERYABLE_LAYERS = 'NO_QUERYABLE_LAYERS';
27+
const CLEAR_WARNING = 'CLEAR_WARNING';
2628

2729
/**
2830
* Private
@@ -67,6 +69,18 @@ function exceptionsFeatureInfo(reqId, exceptions, rParams, lMetaData) {
6769
};
6870
}
6971

72+
function noQueryableLayers() {
73+
return {
74+
type: NO_QUERYABLE_LAYERS
75+
};
76+
}
77+
78+
function clearWarning() {
79+
return {
80+
type: CLEAR_WARNING
81+
};
82+
}
83+
7084
function newMapInfoRequest(reqId, reqConfig) {
7185
return {
7286
type: NEW_MAPINFO_REQUEST,
@@ -197,6 +211,8 @@ module.exports = {
197211
SHOW_REVERSE_GEOCODE,
198212
HIDE_REVERSE_GEOCODE,
199213
GET_VECTOR_INFO,
214+
NO_QUERYABLE_LAYERS,
215+
CLEAR_WARNING,
200216
getFeatureInfo,
201217
changeMapInfoState,
202218
newMapInfoRequest,
@@ -207,5 +223,7 @@ module.exports = {
207223
revGeocodeInfo,
208224
hideMapinfoRevGeocode,
209225
showMapinfoRevGeocode,
210-
getVectorInfo
226+
getVectorInfo,
227+
noQueryableLayers,
228+
clearWarning
211229
};

web/client/components/data/identify/Identify.jsx

+27-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
const React = require('react');
10-
const {Panel, Glyphicon} = require('react-bootstrap');
10+
const {Panel, Glyphicon, Modal} = require('react-bootstrap');
1111
const {findIndex} = require('lodash');
1212

1313
require('./css/identify.css');
@@ -37,6 +37,8 @@ const Identify = React.createClass({
3737
viewerOptions: React.PropTypes.object,
3838
viewer: React.PropTypes.oneOfType([React.PropTypes.object, React.PropTypes.func]),
3939
purgeResults: React.PropTypes.func,
40+
noQueryableLayers: React.PropTypes.func,
41+
clearWarning: React.PropTypes.func,
4042
queryableLayersFilter: React.PropTypes.func,
4143
buildRequest: React.PropTypes.func,
4244
sendRequest: React.PropTypes.func,
@@ -59,7 +61,8 @@ const Identify = React.createClass({
5961
asPanel: React.PropTypes.bool,
6062
headerGlyph: React.PropTypes.string,
6163
closeGlyph: React.PropTypes.string,
62-
allowMultiselection: React.PropTypes.bool
64+
allowMultiselection: React.PropTypes.bool,
65+
warning: React.PropTypes.string
6366
},
6467
getDefaultProps() {
6568
return {
@@ -78,6 +81,8 @@ const Identify = React.createClass({
7881
sendRequest: () => {},
7982
showMarker: () => {},
8083
hideMarker: () => {},
84+
noQueryableLayers: () => {},
85+
clearWarning: () => {},
8186
changeMousePointer: () => {},
8287
showRevGeocode: () => {},
8388
hideRevGeocode: () => {},
@@ -133,7 +138,12 @@ const Identify = React.createClass({
133138
}
134139

135140
});
136-
this.props.showMarker();
141+
if (queryableLayers.length === 0) {
142+
this.props.noQueryableLayers();
143+
} else {
144+
this.props.showMarker();
145+
}
146+
137147
}
138148

139149
if (newProps.enabled && !this.props.enabled) {
@@ -222,6 +232,20 @@ const Identify = React.createClass({
222232
</Draggable>
223233
) : this.renderContent();
224234
}
235+
if (this.props.warning) {
236+
return (<Modal show={true} bsSize="small" onHide={() => {
237+
this.props.clearWarning();
238+
}}>
239+
<Modal.Header className="dialog-error-header-side" closeButton>
240+
<Modal.Title><Message msgId="warning"/></Modal.Title>
241+
</Modal.Header>
242+
<Modal.Body>
243+
<div className="mapstore-error"><Message msgId="identifyNoQueryableLayers"/></div>
244+
</Modal.Body>
245+
<Modal.Footer>
246+
</Modal.Footer>
247+
</Modal>);
248+
}
225249
return null;
226250
},
227251
needsRefresh(props) {

web/client/components/data/identify/__tests__/Identify-test.jsx

+25
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,31 @@ describe('Identify', () => {
227227
expect(spyHideMarker.calls.length).toEqual(1);
228228
});
229229

230+
it('creates the Identify component no queryable layer', () => {
231+
const testHandlers = {
232+
noQueryableLayers: () => {}
233+
};
234+
235+
const spyNoQueryableLayers = expect.spyOn(testHandlers, 'noQueryableLayers');
236+
237+
ReactDOM.render(
238+
<Identify
239+
queryableLayersFilter={() => false}
240+
enabled={true} layers={[{}, {}]} {...testHandlers} buildRequest={() => ({})}
241+
/>,
242+
document.getElementById("container")
243+
);
244+
ReactDOM.render(
245+
<Identify
246+
queryableLayersFilter={() => false}
247+
point={{pixel: {x: 1, y: 1}}}
248+
enabled={true} layers={[{}, {}]} {...testHandlers} buildRequest={() => ({})}
249+
/>,
250+
document.getElementById("container")
251+
);
252+
expect(spyNoQueryableLayers.calls.length).toEqual(1);
253+
});
254+
230255
it('creates the Identify component purge results on point', () => {
231256
const testHandlers = {
232257
purgeResults: () => {}

web/client/plugins/Identify.jsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {createSelector} = require('reselect');
1313
const {mapSelector} = require('../selectors/map');
1414
const {layersSelector} = require('../selectors/layers');
1515

16-
const {getFeatureInfo, getVectorInfo, purgeMapInfoResults, showMapinfoMarker, hideMapinfoMarker, showMapinfoRevGeocode, hideMapinfoRevGeocode} = require('../actions/mapInfo');
16+
const {getFeatureInfo, getVectorInfo, purgeMapInfoResults, showMapinfoMarker, hideMapinfoMarker, showMapinfoRevGeocode, hideMapinfoRevGeocode, noQueryableLayers, clearWarning} = require('../actions/mapInfo');
1717
const {changeMousePointer} = require('../actions/map');
1818
const {changeMapInfoFormat} = require('../actions/mapInfo');
1919

@@ -34,10 +34,11 @@ const selector = createSelector([
3434
layersSelector,
3535
(state) => state.mapInfo && state.mapInfo.clickPoint,
3636
(state) => state.mapInfo && state.mapInfo.showModalReverse,
37-
(state) => state.mapInfo && state.mapInfo.reverseGeocodeData
37+
(state) => state.mapInfo && state.mapInfo.reverseGeocodeData,
38+
(state) => state.mapInfo && state.mapInfo.warning
3839

39-
], (enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData) => ({
40-
enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData
40+
], (enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData, warning) => ({
41+
enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData, warning
4142
}));
4243
// result panel
4344

@@ -89,6 +90,8 @@ const IdentifyPlugin = connect(selector, {
8990
purgeResults: purgeMapInfoResults,
9091
changeMousePointer,
9192
showMarker: showMapinfoMarker,
93+
noQueryableLayers,
94+
clearWarning,
9295
hideMarker: hideMapinfoMarker,
9396
showRevGeocode: showMapinfoRevGeocode,
9497
hideRevGeocode: hideMapinfoRevGeocode

web/client/reducers/mapInfo.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const {
2020
HIDE_MAPINFO_MARKER,
2121
SHOW_REVERSE_GEOCODE,
2222
HIDE_REVERSE_GEOCODE,
23-
GET_VECTOR_INFO
23+
GET_VECTOR_INFO,
24+
NO_QUERYABLE_LAYERS,
25+
CLEAR_WARNING
2426
} = require('../actions/mapInfo');
2527

2628
const {RESET_CONTROLS} = require('../actions/controls');
@@ -45,6 +47,14 @@ function receiveResponse(state, action, type) {
4547

4648
function mapInfo(state = {}, action) {
4749
switch (action.type) {
50+
case NO_QUERYABLE_LAYERS:
51+
return assign({}, state, {
52+
warning: 'NO_QUERYABLE_LAYERS'
53+
});
54+
case CLEAR_WARNING:
55+
return assign({}, state, {
56+
warning: null
57+
});
4858
case CHANGE_MAPINFO_STATE:
4959
return assign({}, state, {
5060
enabled: action.enabled

web/client/translations/data.de-DE

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"about_p6": "MapStore2 ist entwickelt von:",
2121
"enable": "Aktiviere",
2222
"layers": "Ebenen",
23+
"warning": "Warnung",
2324
"layerProperties": {
2425
"windowTitle": "Ebenen Eigenschaften",
2526
"title": "Titel",
@@ -218,6 +219,7 @@
218219
},
219220
"getFeatureInfoTitle": "Feature Info",
220221
"identifyTitle": "Feature Info",
222+
"identifyNoQueryableLayers": "Keine aktive abrufbare Ebene",
221223
"identifyRevGeocodeHeader": "Koordinaten",
222224
"identifyRevGeocodeModalTitle": "Addresse",
223225
"identifyRevGeocodeSubmitText": "Mehr Informationen",

web/client/translations/data.en-US

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"about_p6": "MapStore2 is made by:",
2121
"enable": "Enable",
2222
"layers": "Layers",
23+
"warning": "Warning",
2324
"layerProperties": {
2425
"windowTitle": "Layer Properties",
2526
"title": "Title",
@@ -218,6 +219,7 @@
218219
},
219220
"getFeatureInfoTitle": "Feature Info",
220221
"identifyTitle": "Feature Info",
222+
"identifyNoQueryableLayers": "No active queryable layer",
221223
"identifyRevGeocodeHeader": "Coordinates",
222224
"identifyRevGeocodeModalTitle": "Address",
223225
"identifyRevGeocodeSubmitText": "More Info",

web/client/translations/data.fr-FR

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"about_p6": "MapStore2 est développé par:",
2121
"enable": "Activer",
2222
"layers": "Couches",
23+
"warning": "Attention",
2324
"layerProperties": {
2425
"windowTitle": "Propriétés de la couche",
2526
"title": "Titre",
@@ -219,6 +220,7 @@
219220
},
220221
"getFeatureInfoTitle": "Informations de l'objet",
221222
"identifyTitle": "Informations de l'objet",
223+
"identifyNoQueryableLayers": "Aucune couche active requise",
222224
"identifyRevGeocodeHeader": "Coordonnées",
223225
"identifyRevGeocodeModalTitle": "Adresse",
224226
"identifyRevGeocodeSubmitText": "Plus d'Informations",

web/client/translations/data.it-IT

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"about_p6": "MapStore2 è sviluppato da:",
2121
"enable": "Abilita",
2222
"layers": "Livelli",
23+
"warning": "Attenzione",
2324
"layerProperties": {
2425
"windowTitle": "Proprietà del livello",
2526
"title": "Titolo",
@@ -218,6 +219,7 @@
218219
},
219220
"getFeatureInfoTitle": "Informazioni Sulle Feature",
220221
"identifyTitle": "Informazioni Sulle Feature",
222+
"identifyNoQueryableLayers": "Nessun livello interrogabile attivo",
221223
"identifyRevGeocodeHeader": "Coordinate",
222224
"identifyRevGeocodeModalTitle": "Indirizzo",
223225
"identifyRevGeocodeSubmitText": "Più informazioni",

0 commit comments

Comments
 (0)