From 41abef4837e668cd00ab2fdb0e3483ad7d61bdc1 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Fri, 20 Jan 2017 12:02:33 +0100 Subject: [PATCH] Remove useless code from existing codebase (#1104) - Removed useless properties and code - Add the option to display icon for zoom to feature --- .../data/featuregrid/DockedFeatureGrid.jsx | 32 ++----------------- .../data/featuregrid/FeatureGrid.jsx | 8 +++-- .../data/featuregrid/ZoomToFeatureIcon.jsx | 23 +++++++++++++ 3 files changed, 31 insertions(+), 32 deletions(-) create mode 100644 web/client/components/data/featuregrid/ZoomToFeatureIcon.jsx diff --git a/web/client/components/data/featuregrid/DockedFeatureGrid.jsx b/web/client/components/data/featuregrid/DockedFeatureGrid.jsx index 60c576e514..b6bdaf7eaf 100644 --- a/web/client/components/data/featuregrid/DockedFeatureGrid.jsx +++ b/web/client/components/data/featuregrid/DockedFeatureGrid.jsx @@ -27,9 +27,6 @@ const DockedFeatureGrid = React.createClass({ propTypes: { isNew: React.PropTypes.bool, open: React.PropTypes.bool, - detailOpen: React.PropTypes.bool, - expanded: React.PropTypes.bool, - header: React.PropTypes.string, features: React.PropTypes.oneOfType([ React.PropTypes.array, React.PropTypes.object]), columnsDef: React.PropTypes.array, map: React.PropTypes.object, @@ -42,8 +39,6 @@ const DockedFeatureGrid = React.createClass({ params: React.PropTypes.object, // featureGrigConfigUrl: React.PropTypes.string, profile: React.PropTypes.string, - onDetail: React.PropTypes.func, - onShowDetail: React.PropTypes.func, changeMapView: React.PropTypes.func, // loadFeatureGridConfig: React.PropTypes.func, onExpandFilterPanel: React.PropTypes.func, @@ -51,20 +46,15 @@ const DockedFeatureGrid = React.createClass({ totalFeatures: React.PropTypes.number, pagination: React.PropTypes.bool, featureTypeName: React.PropTypes.string, - ogcVersion: React.PropTypes.string, onQuery: React.PropTypes.func, searchUrl: React.PropTypes.string, filterObj: React.PropTypes.object, dataSourceOptions: React.PropTypes.object, withMap: React.PropTypes.bool.isRequired, - onConfigureQuery: React.PropTypes.func, - attributes: React.PropTypes.array, cleanError: React.PropTypes.func, selectAllToggle: React.PropTypes.func, - templateProfile: React.PropTypes.string, zoomToFeatureAction: React.PropTypes.func, - onClose: React.PropTypes.func, - style: React.PropTypes.object + onClose: React.PropTypes.func }, contextTypes: { messages: React.PropTypes.object @@ -75,16 +65,11 @@ const DockedFeatureGrid = React.createClass({ getDefaultProps() { return { open: false, - detailOpen: true, loadingGrid: false, loadingGridError: null, - attributes: [], profile: null, - expanded: true, - header: "featuregrid.header", features: [], featureTypeName: null, - ogcVersion: "2.0", columnsDef: [], pagination: true, params: {}, @@ -98,16 +83,12 @@ const DockedFeatureGrid = React.createClass({ }, initWidth: 600, withMap: true, - templateProfile: 'default', - onDetail: () => {}, onClose: () => {}, - onShowDetail: () => {}, changeMapView: () => {}, // loadFeatureGridConfig: () => {}, onExpandFilterPanel: () => {}, selectFeatures: () => {}, onQuery: () => {}, - onConfigureQuery: () => {}, cleanError: () => {}, selectAllToggle: () => {} }; @@ -157,14 +138,6 @@ const DockedFeatureGrid = React.createClass({ this.props.onExpandFilterPanel(true); } }, - onResize(event, resize) { - let size = resize.size; - this.setState({width: size.width, height: size.height}); - - }, - getRequestId(params) { - return `${params.startRow}_${params.endRow}_${params.sortModel.map((m) => `${m.colId}_${m.sort}` ).join('_')}`; - }, getSortAttribute(colId) { let col = head(this.props.columnsDef.filter((c) => colId === `properties.${c.field}`)); return col && col.sortAttribute ? col.sortAttribute : (col && col.field || ''); @@ -272,7 +245,8 @@ const DockedFeatureGrid = React.createClass({ height: "100%" }}> } + useIcons={true} + tools={[]} key={"search-results-" + (this.state && this.state.searchN)} className="featureGrid" changeMapView={this.props.changeMapView} diff --git a/web/client/components/data/featuregrid/FeatureGrid.jsx b/web/client/components/data/featuregrid/FeatureGrid.jsx index 641b9e7ff1..ff714c7d3d 100644 --- a/web/client/components/data/featuregrid/FeatureGrid.jsx +++ b/web/client/components/data/featuregrid/FeatureGrid.jsx @@ -8,7 +8,8 @@ const React = require('react'); const {AgGridReact, reactCellRendererFactory} = require('ag-grid-react'); const {keys, isEqual, isFunction} = require('lodash'); -const ZoomToRenderer = require("./ZoomToFeatureRenderer"); +const ZoomToFeatureIcon = require("./ZoomToFeatureIcon"); +const ZoomToFeatureRenderer = require('./ZoomToFeatureRenderer'); const {ButtonToolbar, Button, Glyphicon} = require('react-bootstrap'); const assign = require("object-assign"); @@ -49,7 +50,8 @@ const FeatureGrid = React.createClass({ selectAllActive: React.PropTypes.bool, zoomToFeatureAction: React.PropTypes.func, exportAction: React.PropTypes.func, - tools: React.PropTypes.array + tools: React.PropTypes.array, + useIcons: React.PropTypes.bool }, contextTypes: { messages: React.PropTypes.object @@ -236,7 +238,7 @@ const FeatureGrid = React.createClass({ { onCellClicked: this.zoomToFeature, headerName: '', - cellRenderer: reactCellRendererFactory(ZoomToRenderer), + cellRenderer: reactCellRendererFactory(this.props.useIcons ? ZoomToFeatureIcon : ZoomToFeatureRenderer), suppressSorting: true, suppressMenu: true, pinned: true, diff --git a/web/client/components/data/featuregrid/ZoomToFeatureIcon.jsx b/web/client/components/data/featuregrid/ZoomToFeatureIcon.jsx new file mode 100644 index 0000000000..2c986f9eff --- /dev/null +++ b/web/client/components/data/featuregrid/ZoomToFeatureIcon.jsx @@ -0,0 +1,23 @@ +/** + * Copyright 2017, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ +const React = require('react'); +const {Glyphicon} = require('react-bootstrap'); + +const ZoomToFeatureIcon = React.createClass({ + propTypes: { + params: React.PropTypes.object + }, + render() { + const geometry = this.props.params && this.props.params.data && this.props.params.data.geometry; + return geometry && geometry.coordinates ? ( + + ) : null; + } +}); + +module.exports = ZoomToFeatureIcon;