Themes: allow to easily import tagrenderings and add a prefix key to all tags

This commit is contained in:
Pieter Vander Vennet 2025-04-21 02:51:41 +02:00
parent 4d9bdaf877
commit 01680f236c
9 changed files with 201 additions and 31 deletions

View file

@ -14,7 +14,7 @@ import NearbyImagesCollapsed from "../Image/NearbyImagesCollapsed.svelte"
class NearbyImageVis implements SpecialVisualizationSvelte {
// Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests
args: { name: string; defaultValue?: string; doc: string; required?: boolean }[] = [
args: [
{
name: "mode",
defaultValue: "closed",
@ -65,6 +65,7 @@ export class ImageVisualisations {
args: [
{
name: "image_key",
type: "key",
defaultValue: AllImageProviders.defaultKeys.join(";"),
doc: "The keys given to the images, e.g. if <span class='literal-code'>image</span> is given, the first picture URL will be added as <span class='literal-code'>image</span>, the second as <span class='literal-code'>image:0</span>, the third as <span class='literal-code'>image:1</span>, etc... Multiple values are allowed if ';'-separated ",
},
@ -95,6 +96,7 @@ export class ImageVisualisations {
needsUrls: [Imgur.apiUrl, ...Imgur.supportingUrls],
args: [
{
type: "key",
name: "image_key",
doc: "Image tag to add the URL to (or image-tag:0, image-tag:1 when multiple images are added)",
defaultValue: "panoramax",

View file

@ -1,11 +1,7 @@
import { Store, UIEventSource } from "../Logic/UIEventSource"
import BaseUIElement from "./BaseUIElement"
import ThemeConfig from "../Models/ThemeConfig/ThemeConfig"
import {
FeatureSource,
IndexedFeatureSource,
WritableFeatureSource,
} from "../Logic/FeatureSource/FeatureSource"
import { FeatureSource, IndexedFeatureSource, WritableFeatureSource } from "../Logic/FeatureSource/FeatureSource"
import { OsmConnection } from "../Logic/Osm/OsmConnection"
import { Changes } from "../Logic/Osm/Changes"
import { ExportableMap, MapProperties } from "../Models/MapProperties"
@ -100,7 +96,8 @@ export interface SpecialVisualization {
name: string
defaultValue?: string
doc: string
required?: false | boolean
required?: false | boolean,
type?: "key"
}[]
readonly getLayerDependencies?: (argument: string[]) => string[]
@ -133,7 +130,8 @@ export interface SpecialVisualizationSvelte {
name: string
defaultValue?: string
doc: string
required?: false | boolean
required?: false | boolean,
type?: "key" | string
}[]
readonly getLayerDependencies?: (argument: string[]) => string[]

View file

@ -257,6 +257,7 @@ export default class SpecialVisualizations {
{
name: "key",
defaultValue: "opening_hours",
type: "key",
doc: "The tagkey from which the table is constructed.",
},
{
@ -284,6 +285,7 @@ export default class SpecialVisualizations {
args: [
{
name: "key",
type: "key",
defaultValue: "opening_hours",
doc: "The tagkey from which the opening hours are read.",
},
@ -324,6 +326,7 @@ export default class SpecialVisualizations {
args: [
{
name: "key",
type: "key",
doc: "The key of the tag to give the canonical text for",
required: true,
},
@ -412,6 +415,7 @@ export default class SpecialVisualizations {
args: [
{
name: "key",
type: "key",
doc: "The attribute to interpret as json",
defaultValue: "value",
},
@ -463,6 +467,7 @@ export default class SpecialVisualizations {
args: [
{
name: "key",
type: "key",
defaultValue: "value",
doc: "The key to look for the tags",
},
@ -470,9 +475,7 @@ export default class SpecialVisualizations {
constr(
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
argument: string[]
): BaseUIElement {
const key = argument[0] ?? "value"
return new VariableUiElement(
@ -508,8 +511,7 @@ export default class SpecialVisualizations {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
feature: Feature
): BaseUIElement {
return new SvelteUIElement(DirectionIndicator, { state, feature })
},
@ -520,6 +522,7 @@ export default class SpecialVisualizations {
args: [
{
name: "key",
type: "key",
doc: "The attribute containing the degrees",
defaultValue: "_direction:centerpoint",
},