Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/geosolutions-it/MapStore2
Browse files Browse the repository at this point in the history
…into issue_9396
  • Loading branch information
allyoucanmap committed Sep 8, 2023
2 parents 126b826 + 1f30c78 commit bef0fc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/client/components/mapcontrols/scale/ScaleBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ScaleBox extends React.Component {
}

onComboChange = (event) => {
var selectedZoomLvl = parseInt(event.nativeEvent.target.value, 10);
let selectedZoomLvl = parseInt(event.nativeEvent.target.value, 10);
this.props.onChange(selectedZoomLvl, this.props.scales[selectedZoomLvl]);
};

Expand All @@ -58,22 +58,23 @@ class ScaleBox extends React.Component {
};

render() {
var control = null;
let control = null;
const currentZoomLvl = Math.round(this.props.currentZoomLvl);
if (this.props.readOnly) {
control =
<label>{this.props.template(this.props.scales[this.props.currentZoomLvl], this.props.currentZoomLvl)}</label>
<label>{this.props.template(this.props.scales[currentZoomLvl], currentZoomLvl)}</label>
;
} else if (this.props.useRawInput) {
control =
(<select label={this.props.label} onChange={this.onComboChange} bsSize="small" value={this.props.currentZoomLvl || ""}>
(<select label={this.props.label} onChange={this.onComboChange} bsSize="small" value={currentZoomLvl || ""}>
{this.getOptions()}
</select>)
;
} else {
control =
(<Form inline><FormGroup bsSize="small">
<ControlLabel>{this.props.label}</ControlLabel>
<FormControl componentClass="select" onChange={this.onComboChange} value={this.props.currentZoomLvl || ""}>
<FormControl componentClass="select" onChange={this.onComboChange} value={currentZoomLvl || ""}>
{this.getOptions()}
</FormControl>
</FormGroup></Form>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ describe('ScaleBox', () => {
expect(domLabel).toExist();
expect(domLabel.innerHTML).toContain("Scale:");
});

it('should support not rounded zoom levels', () => {
TestUtils.act(() => { ReactDOM.render(<ScaleBox currentZoomLvl={5.1}/>, document.getElementById('container')); });
const select = document.querySelector('select');
expect(select.value).toBe('5');
});
});

0 comments on commit bef0fc6

Please sign in to comment.