forked from MapComplete/MapComplete
Themes: only add rating-title-icon if 'review_list()' is used in the layer
This commit is contained in:
parent
e71a1c7a3d
commit
6c75553f3f
1 changed files with 9 additions and 7 deletions
|
@ -26,7 +26,7 @@ import predifined_filters from "../../../../assets/layers/filters/filters.json"
|
||||||
import { TagConfigJson } from "../Json/TagConfigJson"
|
import { TagConfigJson } from "../Json/TagConfigJson"
|
||||||
import PointRenderingConfigJson, { IconConfigJson } from "../Json/PointRenderingConfigJson"
|
import PointRenderingConfigJson, { IconConfigJson } from "../Json/PointRenderingConfigJson"
|
||||||
import ValidationUtils from "./ValidationUtils"
|
import ValidationUtils from "./ValidationUtils"
|
||||||
import { RenderingSpecification } from "../../../UI/SpecialVisualization"
|
import { RenderingSpecification, SpecialVisualization } from "../../../UI/SpecialVisualization"
|
||||||
import { QuestionableTagRenderingConfigJson } from "../Json/QuestionableTagRenderingConfigJson"
|
import { QuestionableTagRenderingConfigJson } from "../Json/QuestionableTagRenderingConfigJson"
|
||||||
import { ConfigMeta } from "../../../UI/Studio/configMeta"
|
import { ConfigMeta } from "../../../UI/Studio/configMeta"
|
||||||
import LineRenderingConfigJson from "../Json/LineRenderingConfigJson"
|
import LineRenderingConfigJson from "../Json/LineRenderingConfigJson"
|
||||||
|
@ -1207,13 +1207,15 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
const specialVis: RenderingSpecification[] = ValidationUtils.getAllSpecialVisualisations(
|
const specialVis: Exclude<RenderingSpecification, string>[] = <
|
||||||
<QuestionableTagRenderingConfigJson[]>json.tagRenderings
|
Exclude<RenderingSpecification, string>[]
|
||||||
|
>ValidationUtils.getAllSpecialVisualisations(<any>json.tagRenderings).filter(
|
||||||
|
(rs) => typeof rs !== "string"
|
||||||
)
|
)
|
||||||
|
const funcs = new Set<string>(specialVis.map((rs) => rs.func.funcName))
|
||||||
|
|
||||||
const calledFuncs = new Set<string>(specialVis.map((rs) => rs["func"]))
|
if (funcs.has("list_reviews")) {
|
||||||
if (calledFuncs.has("list_reviews")) {
|
;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("icons.rating")
|
||||||
;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("ratings")
|
|
||||||
}
|
}
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
@ -1244,12 +1246,12 @@ export class PrepareLayer extends Fuse<LayerConfigJson> {
|
||||||
(layer) => new Each(new PreparePointRendering(state, layer))
|
(layer) => new Each(new PreparePointRendering(state, layer))
|
||||||
),
|
),
|
||||||
new SetDefault("titleIcons", ["icons.defaults"]),
|
new SetDefault("titleIcons", ["icons.defaults"]),
|
||||||
|
new AddRatingBadge(),
|
||||||
new On(
|
new On(
|
||||||
"titleIcons",
|
"titleIcons",
|
||||||
(layer) =>
|
(layer) =>
|
||||||
new Concat(new ExpandTagRendering(state, layer, { noHardcodedStrings: true }))
|
new Concat(new ExpandTagRendering(state, layer, { noHardcodedStrings: true }))
|
||||||
),
|
),
|
||||||
new AddRatingBadge(),
|
|
||||||
new ExpandFilter(state)
|
new ExpandFilter(state)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue