diff --git a/modules/util/util.js b/modules/util/util.js index 390396981..f7d9c71c0 100644 --- a/modules/util/util.js +++ b/modules/util/util.js @@ -216,21 +216,29 @@ export function utilDisplayType(id) { } -export function utilDisplayLabel(entity, graphOrGeometry) { +// `utilDisplayLabel` +// Returns a string suitable for display +// By default returns something like name/ref, fallback to preset type, fallback to OSM type +// "Main Street" or "Tertiary Road" +// If `verbose=true`, include both preset name and feature name. +// "Tertiary Road Main Street" +// +export function utilDisplayLabel(entity, graphOrGeometry, verbose) { + var result; var displayName = utilDisplayName(entity); - if (displayName) { - // use the display name if there is one - return displayName; - } var preset = typeof graphOrGeometry === 'string' ? presetManager.matchTags(entity.tags, graphOrGeometry) : presetManager.match(entity, graphOrGeometry); - if (preset && preset.name()) { - // use the preset name if there is a match - return preset.name(); + var presetName = preset && preset.name(); + + if (verbose) { + result = [presetName, displayName].filter(Boolean).join(' '); + } else { + result = displayName || presetName; } - // fallback to the display type (node/way/relation) - return utilDisplayType(entity.id); + + // Fallback to the OSM type (node/way/relation) + return result || utilDisplayType(entity.id); } diff --git a/modules/validations/outdated_tags.js b/modules/validations/outdated_tags.js index a8d1cc54f..079f345fd 100644 --- a/modules/validations/outdated_tags.js +++ b/modules/validations/outdated_tags.js @@ -146,7 +146,9 @@ export function validationOutdatedTags() { if (subtype === 'noncanonical_brand' && isOnlyAddingTags) { messageID += '_incomplete'; } - return t.html(messageID, { feature: utilDisplayLabel(currEntity, context.graph()) }); + return t.html(messageID, { + feature: utilDisplayLabel(currEntity, context.graph(), true /* verbose */) + }); }