From dc959e15f4e6128ffa91d9d7a24b59a5a9cf7332 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 14 Feb 2022 15:59:42 +0100 Subject: [PATCH] Fix filter selection for one option --- Logic/Web/QueryParameters.ts | 2 +- Models/ThemeConfig/FilterConfig.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Logic/Web/QueryParameters.ts b/Logic/Web/QueryParameters.ts index 489b14cb35..a268cb8d22 100644 --- a/Logic/Web/QueryParameters.ts +++ b/Logic/Web/QueryParameters.ts @@ -71,7 +71,7 @@ export class QueryParameters { QueryParameters.knownSources[key] = source; } } - + } private static Serialize() { diff --git a/Models/ThemeConfig/FilterConfig.ts b/Models/ThemeConfig/FilterConfig.ts index e38b645cae..264598cf97 100644 --- a/Models/ThemeConfig/FilterConfig.ts +++ b/Models/ThemeConfig/FilterConfig.ts @@ -18,7 +18,7 @@ export default class FilterConfig { originalTagsSpec: string | AndOrTagConfigJson fields: { name: string, type: string }[] }[]; - public readonly defaultSelection : number + public readonly defaultSelection? : number constructor(json: FilterConfigJson, context: string) { if (json.options === undefined) { @@ -79,7 +79,7 @@ export default class FilterConfig { return {question: question, osmTags: osmTags, fields, originalTagsSpec: option.osmTags}; }); - this.defaultSelection = defaultSelection ?? 0 + this.defaultSelection = defaultSelection if (this.options.some(o => o.fields.length > 0) && this.options.length > 1) { throw `Invalid filter at ${context}: a filter with textfields should only offer a single option.` @@ -103,10 +103,10 @@ export default class FilterConfig { let defaultValue = "" if(this.options.length > 1){ - defaultValue = ""+this.defaultSelection + defaultValue = ""+(this.defaultSelection ?? 0) }else{ // Only a single option - if(this.defaultSelection > 0){ + if(this.defaultSelection === 0){ defaultValue = "true" } }