Skip to content

Commit

Permalink
Merge pull request #1141 from geoadmin/fix-PB-1222-broken-link-to-object
Browse files Browse the repository at this point in the history


PB-1222 : fix mishandling of feature ID that are "number-like"
  • Loading branch information
pakb authored Nov 26, 2024
2 parents f501424 + d0fae6a commit 6180886
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 6180886

Please sign in to comment.