Themes(toilets): improve tagging of wheelchair accessible toilets, various fixes to make this possible

This commit is contained in:
Pieter Vander Vennet 2025-04-05 04:01:19 +02:00
parent 1e84c2cc4d
commit 089017b136
19 changed files with 617 additions and 223 deletions

View file

@ -53,7 +53,7 @@ export default class FeaturePropertiesStore {
public getStore(id: string): UIEventSource<Record<string, string>> {
const store = this._elements.get(id)
if (store === undefined) {
console.error("PANIC: no store for", id)
console.warn("PANIC: no properties store for", id)
}
return store
}

View file

@ -1,42 +1,14 @@
import { Utils } from "../../Utils"
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
export class ThemeMetaTagging {
public static readonly themeName = "usersettings"
public static readonly themeName = "usersettings"
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
feat.properties._description
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
?.at(1)
)
Utils.AddLazyProperty(
feat.properties,
"_d",
() => feat.properties._description?.replace(/&lt;/g, "<")?.replace(/&gt;/g, ">") ?? ""
)
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.href.match(/mastodon|en.osm.town/) !== null
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(
feat.properties,
"_mastodon_candidate",
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
)
feat.properties["__current_backgroun"] = "initial_value"
}
}
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/&lt;/g,'<')?.replace(/&gt;/g,'>') ?? '' )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
feat.properties['__current_backgroun'] = 'initial_value'
}
}

View file

@ -17,7 +17,10 @@
export let layer: LayerConfig
let headerTr = layer.tagRenderings.find((tr) => tr.id === header)
let trgs: TagRenderingConfig[] = []
if (headerTr === undefined) {
console.error("Header tagRendering with ID", header, "was not found")
}
let tagRenderings: TagRenderingConfig[] = []
let seenIds = new Set<string>()
for (const label of labels) {
for (const tr of layer.tagRenderings) {
@ -25,20 +28,30 @@
continue
}
if (label === tr.id || tr.labels.some((l) => l === label)) {
trgs.push(tr)
tagRenderings.push(tr)
seenIds.add(tr.id)
}
}
}
</script>
<AccordionSingle>
{#if tagRenderings.length > 0}
<div class="mb-8">
<AccordionSingle>
<div slot="header">
<TagRenderingAnswer {tags} {layer} config={headerTr} {state} {selectedElement} />
{#if headerTr}
<TagRenderingAnswer {tags} {layer} config={headerTr} {state} {selectedElement} />
{:else}
{header}
{/if}
</div>
{#each trgs as config (config.id)}
{#each tagRenderings as config (config.id)}
{#if config.IsKnown($tags) && (config.condition === undefined || config.condition.matchesProperties($tags))}
<TagRenderingEditableDynamic {tags} {config} {state} {selectedElement} {layer} />
{/if}
{/each}
</AccordionSingle>
</div>
{/if}

View file

@ -31,7 +31,7 @@
*/
export let notForLabels: string[] | undefined = undefined
const _notForLabels = new Set(notForLabels)
let showAllQuestionsAtOnce: Store<boolean> =
export let showAllQuestionsAtOnce: Store<boolean> =
state.userRelatedState?.showAllQuestionsAtOnce ?? new ImmutableStore(false)
function allowed(labels: string[]) {

View file

@ -22,7 +22,8 @@
export let id: string = undefined
if (config === undefined) {
throw "Config is undefined in tagRenderingAnswer"
console.error("TagRenderingAnswer: Config is undefined")
throw ("Config is undefined in tagRenderingAnswer")
}
let trs: Store<{ then: Translation; icon?: string; iconClass?: string }[]> = tags.mapD((tags) =>
Utils.NoNull(config?.GetRenderValues(tags))

View file

@ -1,6 +1,6 @@
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization"
import SvelteUIElement from "../Base/SvelteUIElement"
import { UIEventSource } from "../../Logic/UIEventSource"
import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource"
import { Feature } from "geojson"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import Questionbox from "../Popup/TagRendering/Questionbox.svelte"
@ -31,6 +31,11 @@ class QuestionViz implements SpecialVisualizationSvelte {
name: "blacklisted-labels",
doc: "One or more ';'-separated labels of questions which should _not_ be included. Note that the questionbox which is added by default will blacklist 'hidden'"
},
{
name: "show_all",
default: "user-preference",
doc: "Either `no`, `yes` or `user-preference`. Indicates if all questions should be shown at once"
}
]
svelteBased = true
group: "default"
@ -50,6 +55,13 @@ class QuestionViz implements SpecialVisualizationSvelte {
?.split(";")
?.map((s) => s.trim())
?.filter((s) => s !== "")
const showAll = args[2]
let showAllQuestionsAtOnce: Store<boolean> = state.userRelatedState?.showAllQuestionsAtOnce
if (showAll === "yes") {
showAllQuestionsAtOnce = new ImmutableStore(true)
} else if (showAll === "no") {
showAllQuestionsAtOnce = new ImmutableStore(false)
}
return new SvelteUIElement(Questionbox, {
layer,
tags,
@ -57,6 +69,7 @@ class QuestionViz implements SpecialVisualizationSvelte {
state,
onlyForLabels: labels,
notForLabels: blacklist,
showAllQuestionsAtOnce
})
}
}