Skip to content

Commit

Permalink
PB-1222 : fix mishandling of feature ID that are "number-like"
Browse files Browse the repository at this point in the history
some feature IDs ends with something like "1314.070" and the layer parsing code was transforming them into number, removing the trailing zero from the ID.

This broke many "Link to object" link generated by the backend.

Also fixing an issue with the time slider warning not being wrapped in an array, and generating a crash when its value was not set to something valid
  • Loading branch information
pakb committed Nov 26, 2024
1 parent f501424 commit d0fae6a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/router/storeSync/TimeSliderParamConfig.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ function validateUrlInput(store, query) {
)

if (store.getters.visibleLayers.filter((layer) => layer.hasMultipleTimestamps).length === 0) {
validationObject['warnings'] = new WarningMessage(
'time_slider_no_time_layer_active_url_warning',
{}
if (!validationObject.warnings) {
validationObject.warnings = []
}
validationObject.warnings.push(
new WarningMessage('time_slider_no_time_layer_active_url_warning', {})
)
}
return validationObject
Expand Down
16 changes: 16 additions & 0 deletions src/router/storeSync/__tests__/layersParamParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ describe('Testing layersParamParser', () => {
)
})
})
it('parses correctly a pre-selected feature on a layer', () => {
const layerId = 'fake-layer-id'
const featureId = '1234.050' // some of our IDs end with 0, we have to make sure they are treated as string and not numbers
const result = parseLayersParam(`${layerId}@features=${featureId}`)
checkParsedLayer(result[0], layerId, true, undefined, {
features: featureId,
})
})
it('parses correctly multiple pre-selected features on a single layer', () => {
const layerId = 'fake-layer-id'
const featureIds = ['1234.560', 'iAmSomeId']
const result = parseLayersParam(`${layerId}@features=${featureIds.join(':')}`)
checkParsedLayer(result[0], layerId, true, undefined, {
features: featureIds.join(':'),
})
})

describe('Visibility/Opacity parsing', () => {
it('Parses correctly the visible when specified', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/router/storeSync/layersParamParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export function parseLayersParam(queryValue) {
let parsedValue
if (value === 'true' || value === 'false') {
parsedValue = 'true' === value
} else if (key === 'features') {
// some IDs are "numbers", such as 1314.070, but we NEED the trailing zero
// (they shouldn't be parsed as numbers)
parsedValue = value
} else if (isNumber(value)) {
parsedValue = Number(value)
} else if (key === 'year' && value.toLowerCase() === 'none') {
Expand Down

0 comments on commit d0fae6a

Please sign in to comment.