diff --git a/web/client/components/data/query/QueryBuilder.jsx b/web/client/components/data/query/QueryBuilder.jsx index 98ad7fdb63..b5a32aca31 100644 --- a/web/client/components/data/query/QueryBuilder.jsx +++ b/web/client/components/data/query/QueryBuilder.jsx @@ -63,7 +63,8 @@ class QueryBuilder extends React.Component { autocompleteEnabled: PropTypes.bool, emptyFilterWarning: PropTypes.bool, header: PropTypes.node, - zoom: PropTypes.number + zoom: PropTypes.number, + toolsOptions: PropTypes.object }; static defaultProps = { @@ -127,7 +128,8 @@ class QueryBuilder extends React.Component { onQuery: () => {}, onReset: () => {}, onChangeDrawingStatus: () => {} - } + }, + toolsOptions: {} }; render() { @@ -174,7 +176,7 @@ class QueryBuilder extends React.Component { addButtonIcon={this.props.addButtonIcon} attributePanelExpanded={this.props.attributePanelExpanded} actions={this.props.attributeFilterActions}/> - - } + {this.props.toolsOptions.hideCrossLayer ? null : + />} :
; } diff --git a/web/client/components/data/query/__tests__/QueryBuilder-test.jsx b/web/client/components/data/query/__tests__/QueryBuilder-test.jsx index e575ce904a..7967d63304 100644 --- a/web/client/components/data/query/__tests__/QueryBuilder-test.jsx +++ b/web/client/components/data/query/__tests__/QueryBuilder-test.jsx @@ -141,6 +141,51 @@ describe('QueryBuilder', () => { const queryButton = document.getElementById('query-toolbar-query'); expect(queryButton).toExist(); expect(queryButton.getAttribute("disabled")).toBe(''); + // check presence of attribute, spatial and cross layer filter + expect(document.querySelectorAll('.mapstore-switch-panel').length).toBe(3); + }); + it('tool options', () => { + const groupLevels = 5; + + const groupFields = []; + + const filterFields = [{ + rowId: 100, + groupId: 1, + attribute: "", + operator: null, + value: null, + exception: null + }]; + + const attributes = [{ + id: "Attribute", + type: "list", + values: [ + "attribute1", + "attribute2", + "attribute3", + "attribute4", + "attribute5" + ] + }]; + + const querybuilder = ReactDOM.render( + , + document.getElementById("container") + ); + expect(querybuilder).toExist(); + // only attribute filter should be shown + expect(document.querySelectorAll('.mapstore-switch-panel').length).toBe(1); }); it('creates the QueryBuilder component in error state', () => { diff --git a/web/client/localConfig.json b/web/client/localConfig.json index 03ed955f89..e5a3140b9f 100644 --- a/web/client/localConfig.json +++ b/web/client/localConfig.json @@ -518,6 +518,10 @@ }, { "name": "QueryPanel", "cfg": { + "toolsOptions": { + "hideCrossLayer": true, + "hideSpatialFilter": true + }, "containerPosition": "columns" } }, "Dashboard", "Notifications"], diff --git a/web/client/plugins/QueryPanel.jsx b/web/client/plugins/QueryPanel.jsx index dfed92166a..d980c575ee 100644 --- a/web/client/plugins/QueryPanel.jsx +++ b/web/client/plugins/QueryPanel.jsx @@ -204,7 +204,8 @@ class QueryPanel extends React.Component { activateSettingsTool: PropTypes.bool, visibilityCheckType: PropTypes.string, settingsOptions: PropTypes.object, - layout: PropTypes.object + layout: PropTypes.object, + toolsOptions: PropTypes.object }; static defaultProps = { @@ -226,7 +227,8 @@ class QueryPanel extends React.Component { visibilityCheckType: "checkbox", settingsOptions: {}, querypanelEnabled: false, - layout: {} + layout: {}, + toolsOptions: {} }; componentWillReceiveProps(newProps) { @@ -275,6 +277,7 @@ class QueryPanel extends React.Component { header={} spatialOperations={this.props.spatialOperations} spatialMethodOptions={this.props.spatialMethodOptions} + toolsOptions={this.props.toolsOptions} featureTypeErrorText={}/> ); }; @@ -301,15 +304,18 @@ class QueryPanel extends React.Component { * - blacklist {string[]} a list of banned words excluded from the wfs search * - maxFeatures {number} the maximum features fetched per request * - predicate {string} the cql predicate - * - queriableAttributes {string[]} list of attributes to query on. - * - typeName {string} the workspace + layer name on geosever + * - querableAttributes {string[]} list of attributes to query on. + * - typeName {string} the workspace + layer name on geoserver * - valueField {string} the attribute from features properties used as value/label in the autocomplete list * - srsName {string} The projection of the requested features fetched via wfs * * @prop {object[]} cfg.spatialOperations: The list of geometric operations use to create the spatial filter.
+ * @prop {boolean} cfg.toolsOptions.hideCrossLayer force cross layer to hide + * @prop {boolean} cfg.toolsOptions.hideCrossLayer force cross layer filter panel to hide (when is not used or not usable) + * @prop {boolean} cfg.toolsOptions.hideSpatialFilter force spatial filter panel to hide (when is not used or not usable) * * @example - * // This example configure a layer with polyogns geometry as spatial filter method + * // This example configure a layer with polygons geometry as spatial filter method * "spatialOperations": [ * {"id": "INTERSECTS", "name": "queryform.spatialfilter.operations.intersects"}, * {"id": "BBOX", "name": "queryform.spatialfilter.operations.bbox"}, @@ -339,7 +345,7 @@ class QueryPanel extends React.Component { * "queriableAttributes": ["ATTRIBUTE_X"], * "typeName": "workspace:typeName", * "valueField": "ATTRIBUTE_Y", - * "srsName": "ESPG:3857" + * "srsName": "EPSG:3857" * }, * "customItemClassName": "customItemClassName" * }