Skip to content

Commit

Permalink
Fix #1460 measure panel and tooltip translations (#1467)
Browse files Browse the repository at this point in the history
* fixed measure panel and tooltip translations
* added a test for measurementSupport for leaflet
  • Loading branch information
MV88 authored and Gnafu committed Feb 16, 2017
1 parent c15d518 commit 7fa8228
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
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

0 comments on commit 7fa8228

Please sign in to comment.