Skip to content

Commit

Permalink
Fixes #1686: warning when no queryable layer is available during iden…
Browse files Browse the repository at this point in the history
…tify click (#1700)
  • Loading branch information
mbarto authored Apr 7, 2017
1 parent b41c97a commit f448fbf
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 9 deletions.
20 changes: 19 additions & 1 deletion web/client/actions/mapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const HIDE_MAPINFO_MARKER = 'HIDE_MAPINFO_MARKER';
const SHOW_REVERSE_GEOCODE = 'SHOW_REVERSE_GEOCODE';
const HIDE_REVERSE_GEOCODE = 'HIDE_REVERSE_GEOCODE';
const GET_VECTOR_INFO = 'GET_VECTOR_INFO';
const NO_QUERYABLE_LAYERS = 'NO_QUERYABLE_LAYERS';
const CLEAR_WARNING = 'CLEAR_WARNING';

/**
* Private
Expand Down Expand Up @@ -67,6 +69,18 @@ function exceptionsFeatureInfo(reqId, exceptions, rParams, lMetaData) {
};
}

function noQueryableLayers() {
return {
type: NO_QUERYABLE_LAYERS
};
}

function clearWarning() {
return {
type: CLEAR_WARNING
};
}

function newMapInfoRequest(reqId, reqConfig) {
return {
type: NEW_MAPINFO_REQUEST,
Expand Down Expand Up @@ -197,6 +211,8 @@ module.exports = {
SHOW_REVERSE_GEOCODE,
HIDE_REVERSE_GEOCODE,
GET_VECTOR_INFO,
NO_QUERYABLE_LAYERS,
CLEAR_WARNING,
getFeatureInfo,
changeMapInfoState,
newMapInfoRequest,
Expand All @@ -207,5 +223,7 @@ module.exports = {
revGeocodeInfo,
hideMapinfoRevGeocode,
showMapinfoRevGeocode,
getVectorInfo
getVectorInfo,
noQueryableLayers,
clearWarning
};
30 changes: 27 additions & 3 deletions web/client/components/data/identify/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

const React = require('react');
const {Panel, Glyphicon} = require('react-bootstrap');
const {Panel, Glyphicon, Modal} = require('react-bootstrap');
const {findIndex} = require('lodash');

require('./css/identify.css');
Expand Down Expand Up @@ -37,6 +37,8 @@ const Identify = React.createClass({
viewerOptions: React.PropTypes.object,
viewer: React.PropTypes.oneOfType([React.PropTypes.object, React.PropTypes.func]),
purgeResults: React.PropTypes.func,
noQueryableLayers: React.PropTypes.func,
clearWarning: React.PropTypes.func,
queryableLayersFilter: React.PropTypes.func,
buildRequest: React.PropTypes.func,
sendRequest: React.PropTypes.func,
Expand All @@ -59,7 +61,8 @@ const Identify = React.createClass({
asPanel: React.PropTypes.bool,
headerGlyph: React.PropTypes.string,
closeGlyph: React.PropTypes.string,
allowMultiselection: React.PropTypes.bool
allowMultiselection: React.PropTypes.bool,
warning: React.PropTypes.string
},
getDefaultProps() {
return {
Expand All @@ -78,6 +81,8 @@ const Identify = React.createClass({
sendRequest: () => {},
showMarker: () => {},
hideMarker: () => {},
noQueryableLayers: () => {},
clearWarning: () => {},
changeMousePointer: () => {},
showRevGeocode: () => {},
hideRevGeocode: () => {},
Expand Down Expand Up @@ -133,7 +138,12 @@ const Identify = React.createClass({
}

});
this.props.showMarker();
if (queryableLayers.length === 0) {
this.props.noQueryableLayers();
} else {
this.props.showMarker();
}

}

if (newProps.enabled && !this.props.enabled) {
Expand Down Expand Up @@ -222,6 +232,20 @@ const Identify = React.createClass({
</Draggable>
) : this.renderContent();
}
if (this.props.warning) {
return (<Modal show={true} bsSize="small" onHide={() => {
this.props.clearWarning();
}}>
<Modal.Header className="dialog-error-header-side" closeButton>
<Modal.Title><Message msgId="warning"/></Modal.Title>
</Modal.Header>
<Modal.Body>
<div className="mapstore-error"><Message msgId="identifyNoQueryableLayers"/></div>
</Modal.Body>
<Modal.Footer>
</Modal.Footer>
</Modal>);
}
return null;
},
needsRefresh(props) {
Expand Down
25 changes: 25 additions & 0 deletions web/client/components/data/identify/__tests__/Identify-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,31 @@ describe('Identify', () => {
expect(spyHideMarker.calls.length).toEqual(1);
});

it('creates the Identify component no queryable layer', () => {
const testHandlers = {
noQueryableLayers: () => {}
};

const spyNoQueryableLayers = expect.spyOn(testHandlers, 'noQueryableLayers');

ReactDOM.render(
<Identify
queryableLayersFilter={() => false}
enabled={true} layers={[{}, {}]} {...testHandlers} buildRequest={() => ({})}
/>,
document.getElementById("container")
);
ReactDOM.render(
<Identify
queryableLayersFilter={() => false}
point={{pixel: {x: 1, y: 1}}}
enabled={true} layers={[{}, {}]} {...testHandlers} buildRequest={() => ({})}
/>,
document.getElementById("container")
);
expect(spyNoQueryableLayers.calls.length).toEqual(1);
});

it('creates the Identify component purge results on point', () => {
const testHandlers = {
purgeResults: () => {}
Expand Down
11 changes: 7 additions & 4 deletions web/client/plugins/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {createSelector} = require('reselect');
const {mapSelector} = require('../selectors/map');
const {layersSelector} = require('../selectors/layers');

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

Expand All @@ -34,10 +34,11 @@ const selector = createSelector([
layersSelector,
(state) => state.mapInfo && state.mapInfo.clickPoint,
(state) => state.mapInfo && state.mapInfo.showModalReverse,
(state) => state.mapInfo && state.mapInfo.reverseGeocodeData
(state) => state.mapInfo && state.mapInfo.reverseGeocodeData,
(state) => state.mapInfo && state.mapInfo.warning

], (enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData) => ({
enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData
], (enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData, warning) => ({
enabled, responses, requests, format, map, layers, point, showModalReverse, reverseGeocodeData, warning
}));
// result panel

Expand Down Expand Up @@ -89,6 +90,8 @@ const IdentifyPlugin = connect(selector, {
purgeResults: purgeMapInfoResults,
changeMousePointer,
showMarker: showMapinfoMarker,
noQueryableLayers,
clearWarning,
hideMarker: hideMapinfoMarker,
showRevGeocode: showMapinfoRevGeocode,
hideRevGeocode: hideMapinfoRevGeocode
Expand Down
12 changes: 11 additions & 1 deletion web/client/reducers/mapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const {
HIDE_MAPINFO_MARKER,
SHOW_REVERSE_GEOCODE,
HIDE_REVERSE_GEOCODE,
GET_VECTOR_INFO
GET_VECTOR_INFO,
NO_QUERYABLE_LAYERS,
CLEAR_WARNING
} = require('../actions/mapInfo');

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

function mapInfo(state = {}, action) {
switch (action.type) {
case NO_QUERYABLE_LAYERS:
return assign({}, state, {
warning: 'NO_QUERYABLE_LAYERS'
});
case CLEAR_WARNING:
return assign({}, state, {
warning: null
});
case CHANGE_MAPINFO_STATE:
return assign({}, state, {
enabled: action.enabled
Expand Down
2 changes: 2 additions & 0 deletions web/client/translations/data.de-DE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"about_p6": "MapStore2 ist entwickelt von:",
"enable": "Aktiviere",
"layers": "Ebenen",
"warning": "Warnung",
"layerProperties": {
"windowTitle": "Ebenen Eigenschaften",
"title": "Titel",
Expand Down Expand Up @@ -218,6 +219,7 @@
},
"getFeatureInfoTitle": "Feature Info",
"identifyTitle": "Feature Info",
"identifyNoQueryableLayers": "Keine aktive abrufbare Ebene",
"identifyRevGeocodeHeader": "Koordinaten",
"identifyRevGeocodeModalTitle": "Addresse",
"identifyRevGeocodeSubmitText": "Mehr Informationen",
Expand Down
2 changes: 2 additions & 0 deletions web/client/translations/data.en-US
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"about_p6": "MapStore2 is made by:",
"enable": "Enable",
"layers": "Layers",
"warning": "Warning",
"layerProperties": {
"windowTitle": "Layer Properties",
"title": "Title",
Expand Down Expand Up @@ -218,6 +219,7 @@
},
"getFeatureInfoTitle": "Feature Info",
"identifyTitle": "Feature Info",
"identifyNoQueryableLayers": "No active queryable layer",
"identifyRevGeocodeHeader": "Coordinates",
"identifyRevGeocodeModalTitle": "Address",
"identifyRevGeocodeSubmitText": "More Info",
Expand Down
2 changes: 2 additions & 0 deletions web/client/translations/data.fr-FR
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"about_p6": "MapStore2 est développé par:",
"enable": "Activer",
"layers": "Couches",
"warning": "Attention",
"layerProperties": {
"windowTitle": "Propriétés de la couche",
"title": "Titre",
Expand Down Expand Up @@ -219,6 +220,7 @@
},
"getFeatureInfoTitle": "Informations de l'objet",
"identifyTitle": "Informations de l'objet",
"identifyNoQueryableLayers": "Aucune couche active requise",
"identifyRevGeocodeHeader": "Coordonnées",
"identifyRevGeocodeModalTitle": "Adresse",
"identifyRevGeocodeSubmitText": "Plus d'Informations",
Expand Down
2 changes: 2 additions & 0 deletions web/client/translations/data.it-IT
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"about_p6": "MapStore2 è sviluppato da:",
"enable": "Abilita",
"layers": "Livelli",
"warning": "Attenzione",
"layerProperties": {
"windowTitle": "Proprietà del livello",
"title": "Titolo",
Expand Down Expand Up @@ -218,6 +219,7 @@
},
"getFeatureInfoTitle": "Informazioni Sulle Feature",
"identifyTitle": "Informazioni Sulle Feature",
"identifyNoQueryableLayers": "Nessun livello interrogabile attivo",
"identifyRevGeocodeHeader": "Coordinate",
"identifyRevGeocodeModalTitle": "Indirizzo",
"identifyRevGeocodeSubmitText": "Più informazioni",
Expand Down

0 comments on commit f448fbf

Please sign in to comment.