Skip to content

Commit

Permalink
fix: unclear 'show no data' (#573)
Browse files Browse the repository at this point in the history
Fix: https://dhis2.atlassian.net/browse/DHIS2-15799
Replace empty string by 'No data' in hoverLabel when value is missing.
Handle tranlsation of 'No data' string.
Update associated test.
  • Loading branch information
BRaimbault authored Jun 6, 2024
1 parent 9fcd872 commit 1c31fcc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions jest.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ global.mockMapGL = {
getLayer: jest.fn(),
getSource: jest.fn(),
setFeatureState: jest.fn(),
_getUIString: jest.fn(),
}

global.mockMap = {
Expand Down
1 change: 1 addition & 0 deletions src/controls/controlsLocale.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const controlsLocale = {
'SearchControl.SearchForPlace': 'Search for place or address',
'FitBoundsControl.ZoomToContent': 'Zoom to content',
'HoverLabel.NoData': 'No data',
'MeasureControl.MeasureDistancesAndAreas': 'Measure distances and areas',
'MeasureControl.ClickStartMeasurement':
'Click where you want to start the measurement',
Expand Down
6 changes: 5 additions & 1 deletion src/layers/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Layer extends Evented {
const layers = this.getLayers()
const beforeId = map.getBeforeLayerId()

this.locale = mapgl._getUIString.bind(mapgl)

if (images) {
try {
await addImages(mapgl, images)
Expand Down Expand Up @@ -343,7 +345,9 @@ class Layer extends Evented {
const { properties } = feature
const content = (hoverLabel || label).replace(
/\{ *([\w_-]+) *\}/g,
(str, key) => properties[key] || ''
(str, key) =>
properties[key] ||
(key === 'value' ? this.locale('HoverLabel.NoData') : '')
)

this._map.showLabel(content, evt.lngLat)
Expand Down

0 comments on commit 1c31fcc

Please sign in to comment.