forked from MapComplete/MapComplete
Refactoring: split 'Utils' into multiple files; fix some stray uppercase-method names
This commit is contained in:
parent
81be4db044
commit
3ec89826e4
97 changed files with 884 additions and 921 deletions
|
@ -5,6 +5,7 @@ import { LayerConfigJson } from "../../../src/Models/ThemeConfig/Json/LayerConfi
|
|||
import FilterConfigJson from "../../../src/Models/ThemeConfig/Json/FilterConfigJson"
|
||||
import RewritableConfigJson from "../../../src/Models/ThemeConfig/Json/RewritableConfigJson"
|
||||
import { TagRenderingConfigJson } from "../../../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import { Lists } from "../../../src/Utils/Lists"
|
||||
|
||||
interface ChargingStandard {
|
||||
key: string,
|
||||
|
@ -27,36 +28,36 @@ function colonSplit(value: string): string[] {
|
|||
}
|
||||
|
||||
function loadCsv(file): ChargingStandard[] {
|
||||
const entries: string[] = Utils.NoNull(readFileSync(file, "utf8").split("\n").map(str => str.trim()))
|
||||
const entries: string[] = Lists.noNull(readFileSync(file, "utf8").split("\n").map(str => str.trim()))
|
||||
const header = entries.shift().split(",")
|
||||
|
||||
return Utils.NoNull(entries.map(entry => {
|
||||
const values = entry.split(",").map(str => str.trim())
|
||||
if (values[0] === undefined || values[0] === "") {
|
||||
return undefined
|
||||
return Lists.noNull(entries.map(entry => {
|
||||
const values = entry.split(",").map(str => str.trim())
|
||||
if (values[0] === undefined || values[0] === "") {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const v = {}
|
||||
const colonSeperated = ["commonVoltages", "commonOutputs", "commonCurrents", "countryWhiteList", "countryBlackList", "associatedVehicleTypes", "neverAssociatedWith"]
|
||||
const descriptionTranslations = new Map<string, string>()
|
||||
for (let j = 0; j < header.length; j++) {
|
||||
const key = header[j]
|
||||
if (key.startsWith("description")) {
|
||||
const language = key.substring("description:".length)
|
||||
descriptionTranslations.set(language, values[j])
|
||||
}
|
||||
|
||||
const v = {}
|
||||
const colonSeperated = ["commonVoltages", "commonOutputs", "commonCurrents", "countryWhiteList", "countryBlackList", "associatedVehicleTypes", "neverAssociatedWith"]
|
||||
const descriptionTranslations = new Map<string, string>()
|
||||
for (let j = 0; j < header.length; j++) {
|
||||
const key = header[j]
|
||||
if (key.startsWith("description")) {
|
||||
const language = key.substring("description:".length)
|
||||
descriptionTranslations.set(language, values[j])
|
||||
}
|
||||
|
||||
if (colonSeperated.indexOf(key) >= 0) {
|
||||
v[key] = colonSplit(values[j])
|
||||
} else {
|
||||
v[key] = values[j]
|
||||
}
|
||||
if (colonSeperated.indexOf(key) >= 0) {
|
||||
v[key] = colonSplit(values[j])
|
||||
} else {
|
||||
v[key] = values[j]
|
||||
}
|
||||
v["description"] = descriptionTranslations
|
||||
if (v["id"] === "") {
|
||||
v["id"] = v["key"]
|
||||
}
|
||||
return <any>v
|
||||
}
|
||||
v["description"] = descriptionTranslations
|
||||
if (v["id"] === "") {
|
||||
v["id"] = v["key"]
|
||||
}
|
||||
return <any>v
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -161,7 +162,7 @@ function run(file, protojson) {
|
|||
// We add a second time for any amount to trigger a visualisation; but this is not an answer option
|
||||
const no_ask_json = {
|
||||
if: {
|
||||
and: Utils.NoEmpty([`${e.key}~*`, `${e.key}!=1`, ...e.extraVisualisationCondition.split(";")]),
|
||||
and: Lists.noEmpty([`${e.key}~*`, `${e.key}!=1`, ...e.extraVisualisationCondition.split(";")]),
|
||||
},
|
||||
then: txt,
|
||||
hideInAnswer: true,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -943,9 +943,9 @@
|
|||
"ru": "Onroerend Erfgoed ID:"
|
||||
},
|
||||
"special": {
|
||||
"type": "link",
|
||||
"href": "https://id.erfgoed.net/erfgoedobjecten/{ref:OnroerendErfgoed}",
|
||||
"text": "{ref:OnroerendErfgoed}"
|
||||
"text": "{ref:OnroerendErfgoed}",
|
||||
"type": "link"
|
||||
}
|
||||
},
|
||||
"icon": "./assets/layers/tree/Onroerend_Erfgoed_logo_without_text.svg",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue