diff --git a/web/client/components/data/featuregrid/FeatureGrid.jsx b/web/client/components/data/featuregrid/FeatureGrid.jsx index efafc6e22f..16ced740c2 100644 --- a/web/client/components/data/featuregrid/FeatureGrid.jsx +++ b/web/client/components/data/featuregrid/FeatureGrid.jsx @@ -48,7 +48,8 @@ const FeatureGrid = React.createClass({ toolbar: React.PropTypes.object, dataSource: React.PropTypes.object, selectAll: React.PropTypes.func, - selectAllActive: React.PropTypes.bool + selectAllActive: React.PropTypes.bool, + zoomToFeatureAction: React.PropTypes.func }, contextTypes: { messages: React.PropTypes.object @@ -245,7 +246,12 @@ const FeatureGrid = React.createClass({ zoomToFeature(params) { let geometry = params.data.geometry; if (geometry.coordinates) { - this.changeMapView([geometry], this.props.zoom); + + if (this.props.zoomToFeatureAction) { + this.props.zoomToFeatureAction(params.data); + } else { + this.changeMapView([geometry], this.props.zoom); + } } }, zoomToFeatures() { diff --git a/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx b/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx index 18f4353a87..34abd4ebc2 100644 --- a/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx +++ b/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx @@ -56,7 +56,27 @@ describe("Test FeatureGrid Component", () => { params = {selectedRows: []}; comp.selectFeatures(params); expect(comp).toExist(); + }); + it('Test FeatureGrid custom zoomToFeatures', () => { + let map = { + size: {width: 1360, height: 685}, + center: {x: -98, y: 26, crs: "EPSG:4326"}, + projection: "EPSG:900913" + }; + const testZoomTo = { + action: () => { + return true; + } + }; + const spy = expect.spyOn(testZoomTo, 'action'); + let comp = ReactDOM.render( + , document.getElementById("container")); + expect(comp).toExist(); + let params = {data: {geometry: {coordinates: []}}}; + comp.zoomToFeature(params); + expect(spy).toHaveBeenCalled(); + expect(spy).toHaveBeenCalledWith(params.data); }); });