Fix: generating layeroverview; performance: do not try to download ratings if no ratings element is present
This commit is contained in:
parent
c13d80f062
commit
fc62d41e1b
12 changed files with 67 additions and 15 deletions
|
@ -189,9 +189,6 @@
|
|||
},
|
||||
{
|
||||
"id": "rating",
|
||||
"labels": [
|
||||
"defaults"
|
||||
],
|
||||
"icon": {
|
||||
"class": "w-20 mx-1 flex items-center"
|
||||
},
|
||||
|
|
|
@ -604,7 +604,7 @@
|
|||
],
|
||||
"marker": [
|
||||
{
|
||||
"icon": "statistics:black"
|
||||
"icon": "./assets/svg/statistics.svg"
|
||||
}
|
||||
],
|
||||
"iconSize": "30,30",
|
||||
|
@ -614,4 +614,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@
|
|||
],
|
||||
"marker": [
|
||||
{
|
||||
"icon": "statistics:black"
|
||||
"icon": "./assets/svg/statistics.svg"
|
||||
}
|
||||
],
|
||||
"iconSize": "30,30",
|
||||
|
|
|
@ -467,7 +467,7 @@
|
|||
],
|
||||
"marker": [
|
||||
{
|
||||
"icon": "statistics"
|
||||
"icon": "./assets/svg/statistics.svg"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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[] = <any>Constants._defaultPinIcons
|
||||
|
||||
|
|
|
@ -1193,6 +1193,32 @@ class ExpandMarkerRenderings extends DesugaringStep<IconConfigJson> {
|
|||
}
|
||||
}
|
||||
|
||||
export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
|
||||
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(
|
||||
<QuestionableTagRenderingConfigJson[]>json.tagRenderings
|
||||
)
|
||||
|
||||
const calledFuncs = new Set<string>(specialVis.map((rs) => rs["func"]))
|
||||
if (calledFuncs.has("list_reviews")) {
|
||||
;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("ratings")
|
||||
}
|
||||
return json
|
||||
}
|
||||
}
|
||||
|
||||
export class PrepareLayer extends Fuse<LayerConfigJson> {
|
||||
constructor(state: DesugaringContext) {
|
||||
super(
|
||||
|
@ -1223,6 +1249,7 @@ export class PrepareLayer extends Fuse<LayerConfigJson> {
|
|||
(layer) =>
|
||||
new Concat(new ExpandTagRendering(state, layer, { noHardcodedStrings: true }))
|
||||
),
|
||||
new AddRatingBadge(),
|
||||
new ExpandFilter(state)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ export class DoesImageExist extends DesugaringStep<string> {
|
|||
)
|
||||
} 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(
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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 @@
|
|||
<Teardrop_with_hole_green {color} />
|
||||
{:else if icon === "triangle"}
|
||||
<Triangle {color} />
|
||||
{:else if icon === "brick_wall_square"}
|
||||
<Brick_wall_square {color} />
|
||||
{:else if icon === "brick_wall_round"}
|
||||
<Brick_wall_round {color} />
|
||||
{:else if icon === "gps_arrow"}
|
||||
<Gps_arrow {color} />
|
||||
{:else if icon === "checkmark"}
|
||||
<Checkmark {color} />
|
||||
{:else if icon === "help"}
|
||||
<Help {color} />
|
||||
{:else if icon === "clock"}
|
||||
<Clock {color} />
|
||||
{:else if icon === "close"}
|
||||
<Close {color} />
|
||||
{:else if icon === "invalid"}
|
||||
<Invalid {color} />
|
||||
{:else}
|
||||
<img class="h-full w-full" src={icon} />
|
||||
{/if}
|
||||
|
|
|
@ -78,7 +78,6 @@ export default class Locale {
|
|||
Locale.showLinkToWeblate.setData(Locale.showLinkToWeblate.data || tr)
|
||||
})
|
||||
|
||||
console.log("Initial language:", source, source.data)
|
||||
return source
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue