Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1235. Hide zoom to when loading error occours #1236

Merged
merged 2 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web/client/components/TOC/DefaultLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,17 @@ var DefaultLayer = React.createClass({
if (this.props.activateLegendTool) {
tools.push(
<LayersTool key="toollegend"
className="toc-legendTool"
ref="target"
style={{"float": "right", cursor: "pointer"}}
glyph="list"
onClick={(node) => this.props.onToggle(node.id, node.expanded)}/>
);
}
if (this.props.activateZoomTool && this.props.node.bbox) {
if (this.props.activateZoomTool && this.props.node.bbox && !this.props.node.loadingError) {
tools.push(
<LayersTool key="toolzoom"
className="toc-zoomTool"
ref="target"
style={{"float": "right", cursor: "pointer"}}
glyph="1-full-screen"
Expand Down
34 changes: 32 additions & 2 deletions web/client/components/TOC/__tests__/DefaultLayer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('test DefaultLayer module component', () => {
expect(comp).toExist();
const domNode = ReactDOM.findDOMNode(comp);
expect(domNode).toExist();
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "glyphicon")[1]);
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "toc-legendTool")[0]);
expect(tool).toExist();
tool.click();
expect(spy.calls.length).toBe(1);
Expand Down Expand Up @@ -162,12 +162,42 @@ describe('test DefaultLayer module component', () => {
expect(comp).toExist();
const domNode = ReactDOM.findDOMNode(comp);
expect(domNode).toExist();
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "glyphicon")[1]);
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "toc-zoomTool")[0]);
expect(tool).toExist();
tool.click();
expect(spy.calls.length).toBe(1);
});

it('hide zoom tool when error occours', () => {
const l = {
name: 'layer00',
title: 'Layer',
visibility: true,
storeIndex: 9,
type: 'wms',
loadingError: true,
bbox: {
crs: "EPSG:4326",
bounds: {
minx: 11.0,
maxx: 13.0,
miny: 43.0,
maxy: 44.0
}
}
};
const actions = {
onZoom: () => {}
};
const comp = ReactDOM.render(<Layer visibilityCheckType="checkbox" node={l} activateZoomTool={true} onZoom={actions.onZoom}/>,
document.getElementById("container"));
expect(comp).toExist();
const domNode = ReactDOM.findDOMNode(comp);
expect(domNode).toExist();
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "toc-zoomTool")[0]);
expect(tool).toNotExist();
});

it('tests removelayer tool', () => {
const l = {
name: 'layer000',
Expand Down
6 changes: 4 additions & 2 deletions web/client/components/TOC/fragments/LayersTool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const LayersTool = React.createClass({
onClick: React.PropTypes.func,
style: React.PropTypes.object,
glyph: React.PropTypes.string,
tooltip: React.PropTypes.string
tooltip: React.PropTypes.string,
className: React.PropTypes.string
},
getDefaultProps() {
return {
Expand All @@ -28,7 +29,8 @@ const LayersTool = React.createClass({
};
},
render() {
const tool = (<Glyphicon className="toc-layer-tool" style={this.props.style}
const cn = this.props.className ? " " + this.props.className : "";
const tool = (<Glyphicon className={"toc-layer-tool" + cn} style={this.props.style}
glyph={this.props.glyph}
onClick={(options) => this.props.onClick(this.props.node, options || {})}/>);
return this.props.tooltip ? (
Expand Down