Skip to content

Commit

Permalink
Fix 4007 hide filter layer when no layers are present in TOC (geosolu…
Browse files Browse the repository at this point in the history
…tions-it#4008)

* Fix 4007 hide filter layer whne no layers are present

* even if a group is present with no layers
* Fix tests
  • Loading branch information
MV88 authored and offtherailz committed Aug 9, 2019
1 parent aeb80b9 commit 8bef65d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/client/plugins/TOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class LayerTree extends React.Component {
<Header
title={this.props.mapName}
showTitle={this.props.activateMapTitle}
showFilter={this.props.activateFilterLayer}
showFilter={this.props.activateFilterLayer && (this.props.groups.filter(g => (g.nodes || []).length) || []).length}
showTools={this.props.activateToolsContainer}
onClear={() => { this.props.onSelectNode(); }}
onFilter={this.props.onFilter}
Expand Down
27 changes: 27 additions & 0 deletions web/client/plugins/__tests__/TOC-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('TOCPlugin Plugin', () => {
ReactDOM.render(<Plugin />, document.getElementById("container"));
expect(document.querySelector('.toc-title').textContent).toBe('Annotations');
expect(document.querySelector('.toc-group-title').textContent).toBe('Default');
expect(document.querySelectorAll('.mapstore-filter.form-group').length).toBe(1);
});

it('TOCPlugin hides annotations layer and empty group in cesium mapType', () => {
Expand Down Expand Up @@ -80,4 +81,30 @@ describe('TOCPlugin Plugin', () => {
expect(document.querySelectorAll('.toc-title').length).toBe(1);
expect(document.querySelectorAll('.toc-group-title').length).toBe(1);
});
it('TOCPlugin hides filter layer if no groups and no layers are present', () => {
const { Plugin } = getPluginForTest(TOCPlugin, {
layers: {
groups: [{ id: 'default', title: 'Default', nodes: [] }],
flat: []
},
maptype: {
mapType: 'openlayers'
}
});
ReactDOM.render(<Plugin />, document.getElementById("container"));
expect(document.querySelectorAll('.mapstore-filter.form-group').length).toBe(0);
});
it('TOCPlugin hides filter layer if a group with no layers are present', () => {
const { Plugin } = getPluginForTest(TOCPlugin, {
layers: {
groups: [],
flat: []
},
maptype: {
mapType: 'openlayers'
}
});
ReactDOM.render(<Plugin />, document.getElementById("container"));
expect(document.querySelectorAll('.mapstore-filter.form-group').length).toBe(0);
});
});

0 comments on commit 8bef65d

Please sign in to comment.