Docs: improve tag output

This commit is contained in:
Pieter Vander Vennet 2023-11-13 03:16:24 +01:00
parent 1fea2b56be
commit 818f3e9017
5 changed files with 54 additions and 27 deletions

View file

@ -22,7 +22,6 @@ import { Utils } from "../../Utils"
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
import Table from "../../UI/Base/Table"
import FilterConfigJson from "./Json/FilterConfigJson"
import { And } from "../../Logic/Tags/And"
import { Overpass } from "../../Logic/Osm/Overpass"
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import Svg from "../../Svg"
@ -458,11 +457,6 @@ export default class LayerConfig extends WithContextLoader {
)
}
let neededTags: TagsFilter[] = Utils.NoNull([this.source?.osmTags])
if (this.source?.osmTags["and"] !== undefined) {
neededTags = this.source.osmTags["and"]
}
const tableRows = Utils.NoNull(
this.tagRenderings
.map((tr) => tr.FreeformValues())
@ -523,7 +517,7 @@ export default class LayerConfig extends WithContextLoader {
try {
overpassLink = new Link(
"Execute on overpass",
Overpass.AsOverpassTurboLink(<TagsFilter>new And(neededTags).optimize())
Overpass.AsOverpassTurboLink(<TagsFilter>this.source.osmTags.optimize())
.replaceAll("(", "%28")
.replaceAll(")", "%29")
)
@ -540,12 +534,30 @@ export default class LayerConfig extends WithContextLoader {
const tagsDescription = []
if (this.source !== null) {
tagsDescription.push(
new Title("Basic tags for this layer", 2),
"Elements must have the all of following tags to be shown on this layer:",
new List(neededTags.map((t) => t.asHumanString(true, false, {}))),
overpassLink
)
tagsDescription.push(new Title("Basic tags for this layer", 2))
const neededTags = <TagsFilter>this.source.osmTags.optimize()
if (neededTags["and"]) {
const parts = neededTags["and"]
tagsDescription.push(
"Elements must match **all** of the following expressions:",
parts.map((p, i) => i + ". " + p.asHumanString(true, false, {})).join("\n")
)
} else if (neededTags["or"]) {
const parts = neededTags["or"]
tagsDescription.push(
"Elements must match **any** of the following expressions:",
parts.map((p) => " - " + p.asHumanString(true, false, {})).join("\n")
)
} else {
tagsDescription.push(
"Elements must match the expression **" +
neededTags.asHumanString(true, false, {}) +
"**"
)
}
tagsDescription.push(overpassLink)
} else {
tagsDescription.push("This is a special layer - data is not sourced from OpenStreetMap")
}

View file

@ -746,17 +746,11 @@ export default class TagRenderingConfig {
new Combine([
new FixedUiElement(m.then.txt).SetClass("font-bold"),
" corresponds with ",
new FixedUiElement(m.if.asHumanString(false, false, {})).SetClass(
"code"
),
m.if.asHumanString(true, false, {}),
]),
]
if (m.hideInAnswer === true) {
msgs.push(
new FixedUiElement(
"This option cannot be chosen as answer"
).SetClass("italic")
)
msgs.push("_This option cannot be chosen as answer_")
}
if (m.ifnot !== undefined) {
msgs.push(
@ -774,7 +768,9 @@ export default class TagRenderingConfig {
if (this.condition !== undefined && !this.condition?.matchesProperties({})) {
condition = new Combine([
"This tagrendering is only visible in the popup if the following condition is met:",
new FixedUiElement(this.condition.asHumanString(false, false, {})).SetClass("code"),
new FixedUiElement(
(<TagsFilter>this.condition.optimize()).asHumanString(true, false, {})
).SetClass("code"),
])
}