More work on A11y

This commit is contained in:
Pieter Vander Vennet 2023-12-21 17:36:43 +01:00
parent 87aee9e2b7
commit 6da72b80ef
28 changed files with 398 additions and 209 deletions

View file

@ -105,6 +105,12 @@ export interface MappingConfigJson {
*/
hideInAnswer?: boolean | TagConfigJson
/**
* Also show this 'then'-option if the feature matches these tags.
* Ideal for outdated tags.
*/
alsoShowIf?: TagConfigJson
/**
* question: What tags should be applied if this mapping is _not_ chosen?
*

View file

@ -168,6 +168,7 @@ export interface TagRenderingConfigJson {
* This can be an substituting-tag as well, e.g. {'if': 'addr:street:={_calculated_nearby_streetname}', 'then': '{_calculated_nearby_streetname}'}
*/
if: TagConfigJson
/**
* question: What text should be shown?
*

View file

@ -25,6 +25,7 @@ export interface Icon {}
export interface Mapping {
readonly if: UploadableTag
readonly alsoShowIf: Tag | undefined
readonly ifnot?: UploadableTag
readonly then: TypedTranslation<object>
readonly icon: string
@ -383,7 +384,9 @@ export default class TagRenderingConfig {
}
}
const prioritySearch =
mapping.priorityIf !== undefined ? TagUtils.Tag(mapping.priorityIf) : undefined
mapping.priorityIf !== undefined
? TagUtils.Tag(mapping.priorityIf, `${ctx}.priorityIf`)
: undefined
const mp = <Mapping>{
if: TagUtils.Tag(mapping.if, `${ctx}.if`),
ifnot:
@ -391,6 +394,10 @@ export default class TagRenderingConfig {
? TagUtils.Tag(mapping.ifnot, `${ctx}.ifnot`)
: undefined,
then: Translations.T(mapping.then, `${ctx}.then`),
alsoShowIf:
mapping.alsoShowIf !== undefined
? TagUtils.Tag(mapping.alsoShowIf, `${ctx}.alsoShowIf`)
: undefined,
hideInAnswer,
icon,
iconClass,
@ -530,6 +537,9 @@ export default class TagRenderingConfig {
if (mapping.if.matchesProperties(tags)) {
return mapping
}
if (mapping.alsoShowIf?.matchesProperties(tags)) {
return mapping
}
}
}
@ -818,6 +828,7 @@ export default class TagRenderingConfig {
for (const m of this.mappings ?? []) {
tags.push(m.if)
tags.push(m.priorityIf)
tags.push(m.alsoShowIf)
tags.push(...(m.addExtraTags ?? []))
if (typeof m.hideInAnswer !== "boolean") {
tags.push(m.hideInAnswer)