From 5e991bdc02925b76c5a066dcf3bf00539b9e1842 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 23 Jun 2021 02:41:30 +0200 Subject: [PATCH] Allow to style special visualisations, no cursor if popups are disabled --- Customizations/JSON/LayerConfig.ts | 2 +- UI/ShowDataLayer.ts | 13 +++++++------ UI/SpecialVisualizations.ts | 2 +- UI/SubstitutedTranslation.ts | 2 +- assets/layers/public_bookcase/public_bookcase.json | 4 +++- scripts/ScriptUtils.ts | 4 +++- scripts/generateLayerOverview.ts | 7 +++---- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index 9c143216db..0b14dd1beb 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -183,7 +183,7 @@ export default class LayerConfig { const keys = Array.from(SharedTagRenderings.SharedTagRendering.keys()) - throw `Predefined tagRendering ${renderingJson} not found in ${context}.\n Try one of ${(keys.join(", "))}`; + throw `Predefined tagRendering ${renderingJson} not found in ${context}.\n Try one of ${(keys.join(", "))}\n If you intent to output this text literally, use {\"render\": } instead"}`; } return new TagRenderingConfig(renderingJson, self.source.osmTags, `${context}.tagrendering[${i}]`); }); diff --git a/UI/ShowDataLayer.ts b/UI/ShowDataLayer.ts index b383e19259..485e5cf2e2 100644 --- a/UI/ShowDataLayer.ts +++ b/UI/ShowDataLayer.ts @@ -101,9 +101,13 @@ export default class ShowDataLayer { } const style = layer.GenerateLeafletStyle(tagSource, !(layer.title === undefined && (layer.tagRenderings ?? []).length === 0)); + const baseElement = style.icon.html; + if(!this._enablePopups){ + baseElement.SetStyle("cursor: initial !important") + } return L.marker(latLng, { icon: L.divIcon({ - html: style.icon.html.ConstructElement(), + html: baseElement.ConstructElement(), className: style.icon.className, iconAnchor: style.icon.iconAnchor, iconUrl: style.icon.iconUrl, @@ -119,12 +123,9 @@ export default class ShowDataLayer { console.warn("No layer found for object (probably a now disabled layer)", feature, this._layerDict) return; } - if (layer.title === undefined) { + if (layer.title === undefined || !this._enablePopups) { // No popup action defined -> Don't do anything - return; - } - if(!this._enablePopups){ - // Probably a map in the popup - no popups needed! + // or probably a map in the popup - no popups needed! return; } diff --git a/UI/SpecialVisualizations.ts b/UI/SpecialVisualizations.ts index 1375a4ff8a..40f2849c50 100644 --- a/UI/SpecialVisualizations.ts +++ b/UI/SpecialVisualizations.ts @@ -337,7 +337,7 @@ export default class SpecialVisualizations { return new Combine([ new Title("Special tag renderings", 3), "In a tagrendering, some special values are substituted by an advanced UI-element. This allows advanced features and visualizations to be reused by custom themes or even to query third-party API's.", - "General usage is {func_name()} or {func_name(arg, someotherarg)}. Note that you do not need to use quotes around your arguments, the comma is enough to seperate them. This also implies you cannot use a comma in your args", + "General usage is {func_name()}, {func_name(arg, someotherarg)} or {func_name(args):cssStyle}. Note that you do not need to use quotes around your arguments, the comma is enough to seperate them. This also implies you cannot use a comma in your args", ...helpTexts ] ); diff --git a/UI/SubstitutedTranslation.ts b/UI/SubstitutedTranslation.ts index 2c7f573adf..5bd7c68829 100644 --- a/UI/SubstitutedTranslation.ts +++ b/UI/SubstitutedTranslation.ts @@ -40,7 +40,7 @@ export class SubstitutedTranslation extends VariableUiElement { // We found a special component that should be brought to live const partBefore = SubstitutedTranslation.EvaluateSpecialComponents(matched[1], tags); const argument = matched[2].trim(); - const style = matched[3] ?? "" + const style = matched[3]?.substring(1) ?? "" const partAfter = SubstitutedTranslation.EvaluateSpecialComponents(matched[4], tags); try { const args = knownSpecial.args.map(arg => arg.defaultValue ?? ""); diff --git a/assets/layers/public_bookcase/public_bookcase.json b/assets/layers/public_bookcase/public_bookcase.json index a300a0f0e1..6d8ecc87e5 100644 --- a/assets/layers/public_bookcase/public_bookcase.json +++ b/assets/layers/public_bookcase/public_bookcase.json @@ -72,7 +72,9 @@ ], "tagRenderings": [ "images", - "minimap", + { + "render": "{minimap():height: 9rem; border-radius: 2.5rem; overflow:hidden;border:1px solid gray}" + }, { "render": { "en": "The name of this bookcase is {name}", diff --git a/scripts/ScriptUtils.ts b/scripts/ScriptUtils.ts index 86c3584146..54b340a7cf 100644 --- a/scripts/ScriptUtils.ts +++ b/scripts/ScriptUtils.ts @@ -1,9 +1,11 @@ import {lstatSync, readdirSync, readFileSync} from "fs"; +import {Utils} from "../Utils"; +Utils.runningFromConsole = true import * as https from "https"; import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson"; import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson"; import * as fs from "fs"; -import {Utils} from "../Utils"; + export default class ScriptUtils { diff --git a/scripts/generateLayerOverview.ts b/scripts/generateLayerOverview.ts index 6f09acec27..becfee7218 100644 --- a/scripts/generateLayerOverview.ts +++ b/scripts/generateLayerOverview.ts @@ -1,14 +1,13 @@ import ScriptUtils from "./ScriptUtils"; -import {Utils} from "../Utils"; -import {readFileSync, writeFileSync} from "fs"; - -Utils.runningFromConsole = true +import {writeFileSync} from "fs"; import LayerConfig from "../Customizations/JSON/LayerConfig"; import * as licenses from "../assets/generated/license_info.json" import LayoutConfig from "../Customizations/JSON/LayoutConfig"; import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson"; import {Translation} from "../UI/i18n/Translation"; import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson"; + + // This scripts scans 'assets/layers/*.json' for layer definition files and 'assets/themes/*.json' for theme definition files. // It spits out an overview of those to be used to load them