Skip to content

Commit

Permalink
Partial work for geosolutions-it#1104, enabled search tool if layer h…
Browse files Browse the repository at this point in the history
…as search property
  • Loading branch information
mbarto committed Dec 21, 2016
1 parent 3dfd0ab commit f817fcb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
15 changes: 14 additions & 1 deletion web/client/actions/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const QUERY_ERROR = 'QUERY_ERROR';
const RESET_QUERY = 'RESET_QUERY';

const axios = require('../libs/ajax');

const {toggleControl, setControlProperty} = require('./controls');

function featureTypeSelected(url, typeName) {
return {
type: FEATURE_TYPE_SELECTED,
Expand Down Expand Up @@ -127,6 +130,15 @@ function resetQuery() {
};
}


function toggleQueryPanel(url, name) {
return (dispatch, getState) => {
dispatch(featureTypeSelected(url, name));
dispatch(toggleControl('queryPanel', null));
dispatch(setControlProperty('drawer', 'width', getState().controls.queryPanel.enabled ? 700 : 300));
};
}

module.exports = {
FEATURE_TYPE_SELECTED,
FEATURE_TYPE_LOADED,
Expand All @@ -140,5 +152,6 @@ module.exports = {
describeFeatureType,
loadFeature,
query,
resetQuery
resetQuery,
toggleQueryPanel
};
4 changes: 2 additions & 2 deletions web/client/components/TOC/DefaultLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var DefaultLayer = React.createClass({
groups={this.props.groups}/>
);
}
if (this.props.activateQueryTool) {
if (this.props.activateQueryTool && this.props.node.search) {
tools.push(
<LayersTool key="toolquery"
tooltip="toc.searchFeatures"
Expand All @@ -130,7 +130,7 @@ var DefaultLayer = React.createClass({
ref="target"
style={{"float": "right", cursor: "pointer"}}
glyph="search"
onClick={(node) => this.props.onToggleQuerypanel(node.url, node.name)}/>
onClick={(node) => this.props.onToggleQuerypanel(node.search.url || node.url, node.name)}/>
);
}
return (<div position="collapsible" className="collapsible-toc">
Expand Down
3 changes: 2 additions & 1 deletion web/client/plugins/DrawerMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const {partialRight} = require('lodash');

const Menu = connect((state) => ({
show: state.controls.drawer && state.controls.drawer.enabled,
activeKey: state.controls.drawer && state.controls.drawer.menu
activeKey: state.controls.drawer && state.controls.drawer.menu,
dynamicWidth: state.controls.drawer && state.controls.drawer.width || undefined
}), {
onToggle: toggleControl.bind(null, 'drawer', null),
onChoose: partialRight(setControlProperty.bind(null, 'drawer', 'menu'), true),
Expand Down
11 changes: 3 additions & 8 deletions web/client/plugins/TOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const {Button, Glyphicon} = require('react-bootstrap');
const {changeLayerProperties, changeGroupProperties, toggleNode,
sortNode, showSettings, hideSettings, updateSettings, updateNode, removeNode, getLayerCapabilities} = require('../actions/layers');
const {zoomToExtent} = require('../actions/map');
const {toggleControl} = require('../actions/controls');

const {groupsSelector} = require('../selectors/layers');

Expand Down Expand Up @@ -51,7 +50,7 @@ const {
zoneChange
} = require('../actions/queryform');

const {query, featureTypeSelected, describeFeatureType} = require('../actions/wfsquery');
const {query, toggleQueryPanel, describeFeatureType} = require('../actions/wfsquery');

const {
changeDrawingStatus,
Expand Down Expand Up @@ -184,6 +183,7 @@ const LayerTree = React.createClass({
activateZoomTool: true,
activateSettingsTool: true,
activateRemoveLayer: true,
activateQueryTool: true,
visibilityCheckType: "checkbox",
settingsOptions: {},
querypanelEnabled: false
Expand Down Expand Up @@ -257,12 +257,7 @@ const TOCPlugin = connect(tocSelector, {
retrieveLayerData: getLayerCapabilities,
onToggleGroup: LayersUtils.toggleByType('groups', toggleNode),
onToggleLayer: LayersUtils.toggleByType('layers', toggleNode),
onToggleQuery: (url, name) => {
return (dispatch) => {
dispatch(featureTypeSelected(url, name));
dispatch(toggleControl('queryPanel', null));
};
},
onToggleQuery: toggleQueryPanel,
onSort: LayersUtils.sortUsing(LayersUtils.sortLayers, sortNode),
onSettings: showSettings,
onZoomToExtent: zoomToExtent,
Expand Down
3 changes: 2 additions & 1 deletion web/client/plugins/drawer/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var Menu = React.createClass({
onChoose: React.PropTypes.func,
single: React.PropTypes.bool,
width: React.PropTypes.number,
dynamicWidth: React.PropTypes.number,
overlapMap: React.PropTypes.bool,
changeMapStyle: React.PropTypes.func
},
Expand Down Expand Up @@ -87,7 +88,7 @@ var Menu = React.createClass({
<Sidebar styles={{
sidebar: {
zIndex: 1022,
width: this.props.width
width: this.props.dynamicWidth || this.props.width
},
overlay: {
zIndex: 1021
Expand Down

0 comments on commit f817fcb

Please sign in to comment.