forked from MapComplete/MapComplete
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
|
@ -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)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue