From fc62d41e1b832278bb0c846ffcaa971273419730 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 19 Nov 2023 05:05:15 +0100 Subject: [PATCH] Fix: generating layeroverview; performance: do not try to download ratings if no ratings element is present --- assets/layers/icons/icons.json | 3 --- .../mapcomplete-changes.json | 4 +-- .../mapcomplete-changes.proto.json | 2 +- assets/themes/onwheels/onwheels.json | 2 +- package.json | 2 +- src/Models/Constants.ts | 8 ++++++ .../ThemeConfig/Conversion/PrepareLayer.ts | 27 +++++++++++++++++++ .../ThemeConfig/Conversion/Validation.ts | 2 +- .../ThemeConfig/Conversion/ValidationUtils.ts | 6 +++++ src/UI/Map/Icon.svelte | 19 +++++++++++++ src/UI/i18n/Locale.ts | 1 - src/Utils/svgToPdf.ts | 6 +---- 12 files changed, 67 insertions(+), 15 deletions(-) diff --git a/assets/layers/icons/icons.json b/assets/layers/icons/icons.json index 35e2a7c36..cb5da7543 100644 --- a/assets/layers/icons/icons.json +++ b/assets/layers/icons/icons.json @@ -189,9 +189,6 @@ }, { "id": "rating", - "labels": [ - "defaults" - ], "icon": { "class": "w-20 mx-1 flex items-center" }, diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.json index 153c37965..9b37d1f43 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.json @@ -604,7 +604,7 @@ ], "marker": [ { - "icon": "statistics:black" + "icon": "./assets/svg/statistics.svg" } ], "iconSize": "30,30", @@ -614,4 +614,4 @@ } } ] -} \ No newline at end of file +} diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json index d82eb3043..e7a05ff6e 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json @@ -294,7 +294,7 @@ ], "marker": [ { - "icon": "statistics:black" + "icon": "./assets/svg/statistics.svg" } ], "iconSize": "30,30", diff --git a/assets/themes/onwheels/onwheels.json b/assets/themes/onwheels/onwheels.json index a32ec3c3d..ea77a8823 100644 --- a/assets/themes/onwheels/onwheels.json +++ b/assets/themes/onwheels/onwheels.json @@ -467,7 +467,7 @@ ], "marker": [ { - "icon": "statistics" + "icon": "./assets/svg/statistics.svg" } ] } diff --git a/package.json b/package.json index 17496db23..f1ecefd07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapcomplete", - "version": "0.34.9", + "version": "0.35.0", "repository": "https://github.com/pietervdvn/MapComplete", "description": "A small website to edit OSM easily", "bugs": "https://github.com/pietervdvn/MapComplete/issues", diff --git a/src/Models/Constants.ts b/src/Models/Constants.ts index 25f0de6ba..f15232e3d 100644 --- a/src/Models/Constants.ts +++ b/src/Models/Constants.ts @@ -123,6 +123,14 @@ export default class Constants { "teardrop", "triangle", "crosshair", + "brick_wall_square", + "brick_wall_round", + "gps_arrow", + "checkmark", + "help", + "clock", + "invalid", + "close", ] as const public static readonly defaultPinIcons: string[] = Constants._defaultPinIcons diff --git a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts index a72306dd9..6413e87a5 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts @@ -1193,6 +1193,32 @@ class ExpandMarkerRenderings extends DesugaringStep { } } +export class AddRatingBadge extends DesugaringStep { + constructor() { + super( + "Adds the 'rating'-element if a reviews-element is used in the tagRenderings", + ["titleIcons"], + "AddRatingBadge" + ) + } + + convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson { + if (!json.tagRenderings) { + return json + } + + const specialVis: RenderingSpecification[] = ValidationUtils.getAllSpecialVisualisations( + json.tagRenderings + ) + + const calledFuncs = new Set(specialVis.map((rs) => rs["func"])) + if (calledFuncs.has("list_reviews")) { + ;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("ratings") + } + return json + } +} + export class PrepareLayer extends Fuse { constructor(state: DesugaringContext) { super( @@ -1223,6 +1249,7 @@ export class PrepareLayer extends Fuse { (layer) => new Concat(new ExpandTagRendering(state, layer, { noHardcodedStrings: true })) ), + new AddRatingBadge(), new ExpandFilter(state) ) } diff --git a/src/Models/ThemeConfig/Conversion/Validation.ts b/src/Models/ThemeConfig/Conversion/Validation.ts index ddf224576..9002c3a9a 100644 --- a/src/Models/ThemeConfig/Conversion/Validation.ts +++ b/src/Models/ThemeConfig/Conversion/Validation.ts @@ -110,7 +110,7 @@ export class DoesImageExist extends DesugaringStep { ) } else if (!this.doesPathExist(image)) { context.err( - `Image with path ${image} does not exist; it is used in ${context}.\n Check for typo's and missing directories in the path.` + `Image with path ${image} does not exist.\n Check for typo's and missing directories in the path.` ) } else { context.err( diff --git a/src/Models/ThemeConfig/Conversion/ValidationUtils.ts b/src/Models/ThemeConfig/Conversion/ValidationUtils.ts index 93c507aea..1f8bf800f 100644 --- a/src/Models/ThemeConfig/Conversion/ValidationUtils.ts +++ b/src/Models/ThemeConfig/Conversion/ValidationUtils.ts @@ -9,6 +9,12 @@ export default class ValidationUtils { renderingConfigs: (TagRenderingConfigJson | QuestionableTagRenderingConfigJson)[] ): RenderingSpecification[] { const visualisations: RenderingSpecification[] = [] + if (!Array.isArray(renderingConfigs)) { + throw ( + "Could not inspect renderingConfigs, not an array: " + + JSON.stringify(renderingConfigs) + ) + } for (const renderConfig of renderingConfigs) { visualisations.push(...ValidationUtils.getSpecialVisualisationsWithArgs(renderConfig)) } diff --git a/src/UI/Map/Icon.svelte b/src/UI/Map/Icon.svelte index 00cef96f2..1d250f5e6 100644 --- a/src/UI/Map/Icon.svelte +++ b/src/UI/Map/Icon.svelte @@ -19,6 +19,9 @@ import Teardrop from "../../assets/svg/Teardrop.svelte" import Teardrop_with_hole_green from "../../assets/svg/Teardrop_with_hole_green.svelte" import Triangle from "../../assets/svg/Triangle.svelte" + import Brick_wall_square from "../../assets/svg/Brick_wall_square.svelte"; + import Brick_wall_round from "../../assets/svg/Brick_wall_round.svelte"; + import Gps_arrow from "../../assets/svg/Gps_arrow.svelte"; /** * Renders a single icon. @@ -72,6 +75,22 @@ {:else if icon === "triangle"} + {:else if icon === "brick_wall_square"} + + {:else if icon === "brick_wall_round"} + + {:else if icon === "gps_arrow"} + + {:else if icon === "checkmark"} + + {:else if icon === "help"} + + {:else if icon === "clock"} + + {:else if icon === "close"} + + {:else if icon === "invalid"} + {:else} {/if} diff --git a/src/UI/i18n/Locale.ts b/src/UI/i18n/Locale.ts index 2968f8642..9c88ceb8c 100644 --- a/src/UI/i18n/Locale.ts +++ b/src/UI/i18n/Locale.ts @@ -78,7 +78,6 @@ export default class Locale { Locale.showLinkToWeblate.setData(Locale.showLinkToWeblate.data || tr) }) - console.log("Initial language:", source, source.data) return source } } diff --git a/src/Utils/svgToPdf.ts b/src/Utils/svgToPdf.ts index fffb02fcf..9c715b601 100644 --- a/src/Utils/svgToPdf.ts +++ b/src/Utils/svgToPdf.ts @@ -999,7 +999,7 @@ class SvgToPdfPage { export interface PdfTemplateInfo { pages: string[] - description: string | Translation + description?: string | Translation format: "a3" | "a4" | "a2" orientation: "portrait" | "landscape" isPublic: boolean @@ -1043,22 +1043,18 @@ export class SvgToPdf { format: "a4", orientation: "landscape", pages: ["./assets/templates/CurrentMapWithHeaderA4.svg"], - description: Translations.t.general.download.pdf.current_view_a4, - isPublic: true, }, current_view_a3_landscape: { format: "a3", orientation: "landscape", pages: ["./assets/templates/CurrentMapWithHeader_A3_Landscape.svg"], - description: Translations.t.general.download.pdf.current_view_a3, isPublic: true, }, current_view_a3_portrait: { format: "a3", orientation: "portrait", pages: ["./assets/templates/CurrentMapWithHeader_A3_Portrait.svg"], - description: Translations.t.general.download.pdf.current_view_a3, isPublic: true, }, }