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

PB-1222 : fix mishandling of feature ID that are "number-like" #1141

Merged
merged 1 commit into from
Nov 26, 2024
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
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
Loading