Fix: add support for 'alsoShowIf' in multiAnswers, fix https://github.com/pietervdvn/MapComplete/issues/2293

This commit is contained in:
Pieter Vander Vennet 2025-02-28 12:44:50 +01:00
parent 09b68633d9
commit cddf319c9e
3 changed files with 240 additions and 857 deletions
assets/layers/charging_station
src/Models/ThemeConfig

File diff suppressed because it is too large Load diff

View file

@ -80,6 +80,12 @@
{
"if": "bicycle=yes",
"ifnot": "bicycle=no",
"alsoShowIf": {
"or": [
"bicycle=designated",
"bicycle=customers"
]
},
"then": {
"en": "<b>Bicycles</b> can be charged here",
"nl": "<b>Elektrische fietsen</b> kunnen hier opgeladen worden"
@ -87,6 +93,12 @@
},
{
"if": "motorcar=yes",
"alsoShowIf": {
"or": [
"motorcar=designated",
"motorcar=customers"
]
},
"ifnot": "motorcar=no",
"then": {
"en": "<b>Cars</b> can be charged here",
@ -95,6 +107,12 @@
},
{
"if": "scooter=yes",
"alsoShowIf": {
"or": [
"scooter=designated",
"scooter=customers"
]
},
"ifnot": "scooter=no",
"then": {
"en": "<b>Scooters</b> can be charged here",
@ -103,6 +121,12 @@
},
{
"if": "hgv=yes",
"alsoShowIf": {
"or": [
"hgv=designated",
"hgv=customers"
]
},
"ifnot": "hgv=no",
"then": {
"en": "<b>Heavy good vehicles</b> (such as trucks) can be charged here",
@ -111,6 +135,12 @@
},
{
"if": "bus=yes",
"alsoShowIf": {
"or": [
"bus=designated",
"bus=customers"
]
},
"ifnot": "bus=no",
"then": {
"en": "<b>Buses</b> can be charged here",

View file

@ -479,6 +479,9 @@ export default class TagRenderingConfig {
if (TagUtils.MatchesMultiAnswer(m.if, tags)) {
return true
}
if (m.alsoShowIf?.matchesProperties(tags)) {
return true
}
}
const free = this.freeform?.key
@ -522,14 +525,17 @@ export default class TagRenderingConfig {
then: TypedTranslation<Record<string, string>>
img?: string
}[] = Utils.NoNull(
(this.mappings ?? [])?.map((mapping) => {
(this.mappings ?? [])?.filter((mapping) => {
if (mapping.if === undefined) {
return mapping
return true
}
if (TagUtils.MatchesMultiAnswer(mapping.if, tags)) {
return mapping
return true
}
return undefined
if (mapping.alsoShowIf?.matchesProperties(tags)) {
return true
}
return false
})
)