chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-08-19 23:39:49 +02:00
parent b8847189c2
commit 8d782f1b9d
79 changed files with 2828 additions and 681 deletions

View file

@ -63,15 +63,13 @@ class DirectionAbsolute extends SpecialVisualization {
]
group = "data"
constr({
tags,
args,
}: SpecialVisualisationParams): BaseUIElement {
constr({ tags, args }: SpecialVisualisationParams): BaseUIElement {
const key = args[0] === "" ? "_direction:centerpoint" : args[0]
const offset = args[1] === "" ? 0 : Number(args[1])
return new VariableUiElement(
tags.map((tags) => {
tags
.map((tags) => {
console.log("Direction value", tags[key], key)
return tags[key]
})
@ -118,7 +116,9 @@ class OpeningHoursTableVis extends SpecialVisualizationSvelte {
const openingHoursStore: Store<opening_hours | "error" | undefined> =
OH.CreateOhObjectStore(tags, key, prefix, postfix)
return new SvelteUIElement(OpeningHoursWithError, {
tags, key, opening_hours_obj: openingHoursStore,
tags,
key,
opening_hours_obj: openingHoursStore,
})
}
}
@ -234,7 +234,7 @@ class PresetTypeSelect extends SpecialVisualizationSvelte {
args = []
group = "ui"
constr({ state, tags, feature, layer }: SpecialVisualisationParams,): SvelteUIElement {
constr({ state, tags, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
const t = Translations.t.preset_type
if (layer._basedOn !== layer.id) {
console.warn("Trying to use the _original_ layer")
@ -285,7 +285,7 @@ class PointsInTimeVis extends SpecialVisualization {
args = [
{
name: "key",
type:"key",
type: "key",
required: true,
doc: "The key out of which the points_in_time will be parsed",
},
@ -305,22 +305,26 @@ class PointsInTimeVis extends SpecialVisualization {
}
class KnownIcons extends SpecialVisualization {
docs = "Displays all icons from the specified tagRenderings (if they are known and have an icon) together, e.g. to give a summary of the dietary options"
docs =
"Displays all icons from the specified tagRenderings (if they are known and have an icon) together, e.g. to give a summary of the dietary options"
needsUrls = []
group = "UI"
funcName = "show_icons"
args: SpecialVisualisationArg[] = [{
name: "labels",
doc: "A ';'-separated list of labels and/or ids of tagRenderings",
type: "key",
required: true,
}, {
name: "class",
doc: "CSS-classes of the container, space-separated",
type: "css",
required: false,
defaultValue: "inline-flex mx-4",
}]
args: SpecialVisualisationArg[] = [
{
name: "labels",
doc: "A ';'-separated list of labels and/or ids of tagRenderings",
type: "key",
required: true,
},
{
name: "class",
doc: "CSS-classes of the container, space-separated",
type: "css",
required: false,
defaultValue: "inline-flex mx-4",
},
]
private static readonly emojiHeights = {
small: "2rem",
@ -329,32 +333,34 @@ class KnownIcons extends SpecialVisualization {
}
constr(options: SpecialVisualisationParams): BaseUIElement {
const labels = new Set(options.args[0].split(";").map(s => s.trim()))
const labels = new Set(options.args[0].split(";").map((s) => s.trim()))
const matchingTrs = options.layer.tagRenderings.filter(
tr => labels.has(tr.id) || tr.labels.some(l => labels.has(l)),
(tr) => labels.has(tr.id) || tr.labels.some((l) => labels.has(l))
)
return new VariableUiElement(options.tags.map(tags =>
new Combine(matchingTrs.map(tr => {
const mapping = tr.GetRenderValueWithImage(tags)
if (!mapping?.icon) {
return undefined
}
return new VariableUiElement(
options.tags.map((tags) =>
new Combine(
matchingTrs.map((tr) => {
const mapping = tr.GetRenderValueWithImage(tags)
if (!mapping?.icon) {
return undefined
}
return new SvelteUIElement(Marker, {
emojiHeight: KnownIcons.emojiHeights[mapping.iconClass] ?? "2rem",
clss: `mapping-icon-${mapping.iconClass ?? "small"}`,
icons: mapping.icon,
size: twJoin(
"shrink-0",
`mapping-icon-${mapping.iconClass ?? "small"}-height mapping-icon-${
mapping.iconClass ?? "small"
}-width`),
})
})
).SetClass(options.args[1] ?? "inline-flex mx-4")
))
return new SvelteUIElement(Marker, {
emojiHeight: KnownIcons.emojiHeights[mapping.iconClass] ?? "2rem",
clss: `mapping-icon-${mapping.iconClass ?? "small"}`,
icons: mapping.icon,
size: twJoin(
"shrink-0",
`mapping-icon-${mapping.iconClass ?? "small"}-height mapping-icon-${
mapping.iconClass ?? "small"
}-width`
),
})
})
).SetClass(options.args[1] ?? "inline-flex mx-4")
)
)
}
}