Skip to content

Commit

Permalink
Fix #2573. Empty filter notification with cross layer filter (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored Jan 30, 2018
1 parent 1ad9c6e commit 779d321
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion web/client/components/data/query/QueryToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ class QueryToolbar extends React.Component {
!fieldsWithValues && !this.props.spatialField.geometry;


const showTooltip = this.props.emptyFilterWarning && this.props.filterFields.filter((field) => field.value).length === 0 && !this.props.spatialField.geometry;
const showTooltip = this.props.emptyFilterWarning
&& this.props.filterFields.filter((field) => field.value).length === 0
&& !this.props.spatialField.geometry
&& !(this.props.crossLayerFilter && this.props.crossLayerFilter.attribute && this.props.crossLayerFilter.operation);

const buttons = [{
tooltipId: "queryform.reset",
Expand All @@ -98,6 +101,7 @@ class QueryToolbar extends React.Component {
tooltipId: showTooltip ? "queryform.emptyfilter" : this.props.queryBtnMsgId,
disabled: queryDisabled,
glyph: this.props.queryBtnGlyph,
className: showTooltip ? "square-button-md showWarning" : "square-button-md",
id: "query-toolbar-query",
onClick: this.search
}];
Expand Down
42 changes: 42 additions & 0 deletions web/client/components/data/query/__tests__/QueryToolbar-test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 ReactDOM = require('react-dom');

const expect = require('expect');
const QueryToolbar = require('../QueryToolbar');
describe('QueryToolbar component', () => {
beforeEach((done) => {
document.body.innerHTML = '<div id="container"></div>';
setTimeout(done);
});
afterEach((done) => {
ReactDOM.unmountComponentAtNode(document.getElementById("container"));
document.body.innerHTML = '';
setTimeout(done);
});
it('QueryToolbar rendering with defaults', () => {
ReactDOM.render(<QueryToolbar />, document.getElementById("container"));
const container = document.getElementById('container');
const el = container.querySelector('.query-toolbar');
expect(el).toExist();
});
it('QueryToolbar check empty filter warning', () => {
ReactDOM.render(<QueryToolbar emptyFilterWarning allowEmptyFilter spatialField={{}} crossLayerFilter={{attribute: "ATTR", operation: undefined}}/>, document.getElementById("container"));
const container = document.getElementById('container');
const el = container.querySelector('#query-toolbar-query.showWarning');
expect(el).toExist();
ReactDOM.render(<QueryToolbar emptyFilterWarning allowEmptyFilter spatialField={{}} crossLayerFilter={{attribute: "ATTR", operation: "INTERSECT"}}/>, document.getElementById("container"));
expect(container.querySelector('#query-toolbar-query.showWarning')).toNotExist();
expect(container.querySelector('#query-toolbar-query')).toExist();
ReactDOM.render(<QueryToolbar emptyFilterWarning allowEmptyFilter spatialField={{geometry: {}}} crossLayerFilter={{attribute: "ATTR", operation: undefined}}/>, document.getElementById("container"));
expect(container.querySelector('#query-toolbar-query.showWarning')).toNotExist();

});
});

0 comments on commit 779d321

Please sign in to comment.