Skip to content

Commit

Permalink
Remove useless code from existing codebase (geosolutions-it#1104)
Browse files Browse the repository at this point in the history
 - Removed useless properties and code
 - Add the option to display icon for zoom to feature
  • Loading branch information
offtherailz committed Jan 20, 2017
1 parent a56dc1a commit 41abef4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
32 changes: 3 additions & 29 deletions web/client/components/data/featuregrid/DockedFeatureGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -42,29 +39,22 @@ 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,
selectFeatures: React.PropTypes.func,
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
Expand All @@ -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: {},
Expand All @@ -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: () => {}
};
Expand Down Expand Up @@ -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 || '');
Expand Down Expand Up @@ -272,7 +245,8 @@ const DockedFeatureGrid = React.createClass({
height: "100%"
}}>
<FeatureGrid
tools={<Button onClick={this.props.onClose} ><Glyphicon glyph="1-close" /><I18N.Message msgId="close"/></Button>}
useIcons={true}
tools={[<Button onClick={this.props.onClose} ><Glyphicon glyph="1-close" /><I18N.Message msgId="close"/></Button>]}
key={"search-results-" + (this.state && this.state.searchN)}
className="featureGrid"
changeMapView={this.props.changeMapView}
Expand Down
8 changes: 5 additions & 3 deletions web/client/components/data/featuregrid/FeatureGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions web/client/components/data/featuregrid/ZoomToFeatureIcon.jsx
Original file line number Diff line number Diff line change
@@ -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 ? (
<Glyphicon glyph="search" width={16}/>
) : null;
}
});

module.exports = ZoomToFeatureIcon;

0 comments on commit 41abef4

Please sign in to comment.