Support a more verbose format for listing issues

Includes the feature type in the label
(re: https://github.com/osmlab/name-suggestion-index/issues/4543#issuecomment-791919134)
This commit is contained in:
Bryan Housel
2021-03-08 12:15:17 -05:00
parent a827e13a6d
commit c3e9e8c8ff
2 changed files with 21 additions and 11 deletions

View File

@@ -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);
}

View File

@@ -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 */)
});
}