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

Multi identify #1338

Merged
merged 2 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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: 7 additions & 3 deletions web/client/components/data/identify/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const Identify = React.createClass({
bodyClassName: React.PropTypes.string,
asPanel: React.PropTypes.bool,
headerGlyph: React.PropTypes.string,
closeGlyph: React.PropTypes.string
closeGlyph: React.PropTypes.string,
allowMultiselection: React.PropTypes.bool
},
getDefaultProps() {
return {
Expand Down Expand Up @@ -103,12 +104,15 @@ const Identify = React.createClass({
bodyClassName: "panel-body",
asPanel: true,
headerGlyph: "info-sign",
closeGlyph: ""
closeGlyph: "",
allowMultiselection: false
};
},
componentWillReceiveProps(newProps) {
if (this.needsRefresh(newProps)) {
this.props.purgeResults();
if (!newProps.point.modifiers || newProps.point.modifiers.ctrl !== true || !newProps.allowMultiselection) {
this.props.purgeResults();
}
const queryableLayers = newProps.layers.filter(newProps.queryableLayersFilter);
queryableLayers.forEach((layer) => {
const {url, request, metadata} = this.props.buildRequest(layer, newProps);
Expand Down
21 changes: 21 additions & 0 deletions web/client/components/data/identify/__tests__/Identify-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,27 @@ describe('Identify', () => {
expect(spyPurgeResults.calls.length).toEqual(2);
});

it('creates the Identify component does not purge if multiselection enabled', () => {
const testHandlers = {
purgeResults: () => {}
};

const spyPurgeResults = expect.spyOn(testHandlers, 'purgeResults');

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

it('creates the Identify component uses custom viewer', () => {
const Viewer = (props) => <span className="myviewer">{props.responses.length}</span>;
const identify = ReactDOM.render(
Expand Down
5 changes: 5 additions & 0 deletions web/client/components/map/leaflet/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ let LeafletMap = React.createClass({
latlng: {
lat: event.latlng.lat,
lng: event.latlng.lng
},
modifiers: {
alt: event.originalEvent.altKey,
ctrl: event.originalEvent.ctrlKey,
shift: event.originalEvent.shiftKey
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions web/client/components/map/leaflet/__tests__/Map-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ describe('LeafletMap', () => {
expect(spy.calls[0].arguments.length).toEqual(1);
expect(spy.calls[0].arguments[0].pixel).toExist();
expect(spy.calls[0].arguments[0].latlng).toExist();
expect(spy.calls[0].arguments[0].modifiers).toExist();
expect(spy.calls[0].arguments[0].modifiers.alt).toEqual(false);
expect(spy.calls[0].arguments[0].modifiers.ctrl).toEqual(false);
expect(spy.calls[0].arguments[0].modifiers.shift).toEqual(false);
done();
}, 600);


});

it('check if the map changes when receive new props', () => {
Expand Down
5 changes: 5 additions & 0 deletions web/client/components/map/openlayers/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ var OpenlayersMap = React.createClass({
latlng: {
lat: coords[1],
lng: tLng
},
modifiers: {
alt: event.originalEvent.altKey,
ctrl: event.originalEvent.ctrlKey,
shift: event.originalEvent.shiftKey
}
});
}
Expand Down