forked from MapComplete/MapComplete
Fix: allow to delete freeform values in more cases
This commit is contained in:
parent
c2d8ff906b
commit
9b78838745
3 changed files with 13 additions and 3 deletions
|
@ -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]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, string>): string {
|
||||
for (const k in dict) {
|
||||
template = template.replace(new RegExp("\\{" + k + "\\}", "g"), dict[k])
|
||||
|
|
|
@ -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 @@
|
|||
<!-- TagRenderingQuestion-buttons -->
|
||||
<slot name="cancel" />
|
||||
<slot name="save-button" {selectedTags}>
|
||||
{#if allowDeleteOfFreeform && mappings?.length === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""}
|
||||
{#if allowDeleteOfFreeform && (mappings?.length ?? 0) === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""}
|
||||
<button class="primary flex" on:click|stopPropagation|preventDefault={onSave}>
|
||||
<TrashIcon class="w-6 h-6 text-red-500" />
|
||||
<Tr t={Translations.t.general.eraseValue}/>
|
||||
|
|
Loading…
Reference in a new issue