diff --git a/src/Logic/Tags/ComparingTag.ts b/src/Logic/Tags/ComparingTag.ts index 981a64a92e..56da517ee0 100644 --- a/src/Logic/Tags/ComparingTag.ts +++ b/src/Logic/Tags/ComparingTag.ts @@ -1,6 +1,7 @@ import { TagsFilter } from "./TagsFilter" import { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson" import { Tag } from "./Tag" +import { ExpressionSpecification } from "maplibre-gl" export default class ComparingTag implements TagsFilter { private readonly _key: string @@ -12,7 +13,7 @@ export default class ComparingTag implements TagsFilter { key: string, predicate: (value: string | undefined) => boolean, representation: "<" | ">" | "<=" | ">=", - boundary: string + boundary: string, ) { this._key = key this._predicate = predicate @@ -125,4 +126,8 @@ export default class ComparingTag implements TagsFilter { visit(f: (TagsFilter) => void) { f(this) } + + asMapboxExpression(): ExpressionSpecification { + return [this._representation, ["get", this._key], this._boundary] + } } diff --git a/src/Logic/Tags/SubstitutingTag.ts b/src/Logic/Tags/SubstitutingTag.ts index 6e9d293116..bf13dc7c35 100644 --- a/src/Logic/Tags/SubstitutingTag.ts +++ b/src/Logic/Tags/SubstitutingTag.ts @@ -2,6 +2,7 @@ import { TagsFilter } from "./TagsFilter" import { Tag } from "./Tag" import { Utils } from "../../Utils" import { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson" +import { ExpressionSpecification } from "maplibre-gl" /** * The substituting-tag uses the tags of a feature a variables and replaces them. @@ -23,6 +24,10 @@ export default class SubstitutingTag implements TagsFilter { this._invert = invert } + asMapboxExpression(): ExpressionSpecification { + throw new Error("Method not implemented.") + } + private static substituteString(template: string, dict: Record): string { for (const k in dict) { template = template.replace(new RegExp("\\{" + k + "\\}", "g"), dict[k]) diff --git a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte index ae33fc1bab..0bdce9a730 100644 --- a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte +++ b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte @@ -153,7 +153,7 @@ } }) $: { - if (allowDeleteOfFreeform && $freeformInput === undefined && $freeformInputUnvalidated === "" && mappings?.length === 0) { + if (allowDeleteOfFreeform && $freeformInput === undefined && $freeformInputUnvalidated === "" && (mappings?.length ?? 0) === 0) { selectedTags = new Tag(config.freeform.key, "") } else { @@ -394,7 +394,7 @@ - {#if allowDeleteOfFreeform && mappings?.length === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""} + {#if allowDeleteOfFreeform && (mappings?.length ?? 0) === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""}