forked from MapComplete/MapComplete
refactoring: Fix generate:layeroverview
This commit is contained in:
parent
41e6a2c760
commit
9b2f92dedc
25 changed files with 194 additions and 216 deletions
36
Models/ThemeConfig/Conversion/ValidationUtils.ts
Normal file
36
Models/ThemeConfig/Conversion/ValidationUtils.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { TagRenderingConfigJson } from "../Json/TagRenderingConfigJson"
|
||||
import { Utils } from "../../../Utils"
|
||||
import SpecialVisualizations from "../../../UI/SpecialVisualizations"
|
||||
|
||||
export default class ValidationUtils {
|
||||
/**
|
||||
* Gives all the (function names of) used special visualisations
|
||||
* @param renderingConfig
|
||||
*/
|
||||
public static getSpecialVisualisations(renderingConfig: TagRenderingConfigJson): string[] {
|
||||
const translations: any[] = Utils.NoNull([
|
||||
renderingConfig.render,
|
||||
...(renderingConfig.mappings ?? []).map((m) => m.then),
|
||||
])
|
||||
const all: string[] = []
|
||||
for (let translation of translations) {
|
||||
if (typeof translation == "string") {
|
||||
translation = { "*": translation }
|
||||
}
|
||||
|
||||
for (const key in translation) {
|
||||
if (!translation.hasOwnProperty(key)) {
|
||||
continue
|
||||
}
|
||||
|
||||
const template = translation[key]
|
||||
const parts = SpecialVisualizations.constructSpecification(template)
|
||||
const specials = parts
|
||||
.filter((p) => typeof p !== "string")
|
||||
.map((special) => special["func"].funcName)
|
||||
all.push(...specials)
|
||||
}
|
||||
}
|
||||
return all
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue