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 #1460 measure panel and tooltip translations #1467

Merged
merged 4 commits into from
Feb 16, 2017
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
11 changes: 6 additions & 5 deletions web/client/components/map/leaflet/MeasurementSupport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const MeasurementSupport = React.createClass({
};
},
componentWillReceiveProps(newProps) {
var drawingStrings = this.props.messages || (this.context.messages) ? this.context.messages.drawLocal : false;
if (drawingStrings) {
L.drawLocal = drawingStrings;
}

if (newProps.measurement.geomType && newProps.measurement.geomType !== this.props.measurement.geomType ) {
this.addDrawInteraction(newProps);
}
Expand Down Expand Up @@ -66,6 +61,12 @@ const MeasurementSupport = React.createClass({
}
},
render() {
// moved here the translations because when language changes it is forced a render of this component. (see connect of measure plugin)
var drawingStrings = this.props.messages || (this.context.messages ? this.context.messages.drawLocal : false);
if (drawingStrings) {
L.drawLocal = drawingStrings;
}

return null;
},
updateMeasurementResults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ describe('Leaflet MeasurementSupport', () => {
expect(cmp).toExist();
});

it('test rendering', () => {
let myMessages = {message: "message"};
let drawLocal = L.drawLocal;
L.drawLocal = null;
const cmp = ReactDOM.render(
<MeasurementSupport
messages={myMessages}
/>
, msNode);
expect(cmp).toExist();
expect(L.drawLocal).toEqual(myMessages);
// restoring old value of drawLocal because other test would fail otherwise.
// L is global so drawLocal need to be restore to default value
L.drawLocal = drawLocal;
});

it('test if a new layer is added to the map in order to allow drawing.', () => {
let map = L.map("map", {
center: [51.505, -0.09],
Expand Down
2 changes: 1 addition & 1 deletion web/client/plugins/Measure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const MeasurePlugin = connect((state) => {
};
}, {
toggleMeasure: changeMeasurement
})(MeasureComponent);
}, null, {pure: false})(MeasureComponent);

module.exports = {
MeasurePlugin: assign(MeasurePlugin, {
Expand Down