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

File diff suppressed because it is too large Load diff

View file

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

View file

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