Themes: allow to have a non-number type together with a unit

This commit is contained in:
Pieter Vander Vennet 2024-04-28 22:13:25 +02:00
parent b4163897e8
commit 4ccfe3efe4
5 changed files with 93 additions and 54 deletions

View file

@ -97,18 +97,6 @@ export default class LayerConfig extends WithContextLoader {
this.allowSplit = json.allowSplit ?? false
this.name = Translations.T(json.name, translationContext + ".name")
if (json.units !== undefined && !Array.isArray(json.units)) {
throw (
"At " +
context +
".units: the 'units'-section should be a list; you probably have an object there"
)
}
this.units = [].concat(
...(json.units ?? []).map((unitJson, i) =>
Unit.fromJson(unitJson, `${context}.unit[${i}]`)
)
)
if (json.description !== undefined) {
if (Object.keys(json.description).length === 0) {
@ -280,6 +268,18 @@ export default class LayerConfig extends WithContextLoader {
this.id + ".tagRenderings[" + i + "]"
)
)
if (json.units !== undefined && !Array.isArray(json.units)) {
throw (
"At " +
context +
".units: the 'units'-section should be a list; you probably have an object there"
)
}
this.units = [].concat(
...(json.units ?? []).map((unitJson, i) =>
Unit.fromJson(unitJson, this.tagRenderings,`${context}.unit[${i}]`)
)
)
if (
json.filter !== undefined &&