Added entity display name or preset name to the disconnected highway message

This commit is contained in:
Quincy Morgan
2018-12-18 18:05:27 -05:00
parent c1240af464
commit 858a9606d5
4 changed files with 15 additions and 5 deletions

View File

@@ -623,7 +623,7 @@ en:
on_wiki: "{tag} on wiki.osm.org"
used_with: "used with {type}"
validations:
disconnected_highway: Disconnected highway
disconnected_highway: "{entityLabel} is disconnected from other highways."
disconnected_highway_tooltip: "Roads should be connected to other roads or building entrances."
old_multipolygon: Multipolygon tags on outer way
old_multipolygon_tooltip: "This style of multipolygon is deprecated. Please assign the tags to the parent multipolygon instead of the outer way."

View File

@@ -760,7 +760,7 @@
"used_with": "used with {type}"
},
"validations": {
"disconnected_highway": "Disconnected highway",
"disconnected_highway": "{entityLabel} is disconnected from other highways.",
"disconnected_highway_tooltip": "Roads should be connected to other roads or building entrances.",
"old_multipolygon": "Multipolygon tags on outer way",
"old_multipolygon_tooltip": "This style of multipolygon is deprecated. Please assign the tags to the parent multipolygon instead of the outer way.",

View File

@@ -282,7 +282,7 @@ export function coreHistory(context) {
validate: function(changes) {
return _flatten(_map(Validations, function(fn) {
return fn()(changes, _stack[_index].graph);
return fn(context)(changes, _stack[_index].graph);
}));
},

View File

@@ -1,7 +1,8 @@
import { t } from '../util/locale';
import { utilDisplayName } from '../util';
export function validationDisconnectedHighway() {
export function validationDisconnectedHighway(context) {
function isDisconnectedHighway(entity, graph) {
if (!entity.tags.highway) return false;
@@ -28,9 +29,18 @@ export function validationDisconnectedHighway() {
var entity = changes.created[i];
if (isDisconnectedHighway(entity, graph)) {
var entityLabel = utilDisplayName(entity);
if (!entityLabel) {
var preset = context.presets().match(entity, graph);
if (preset && preset.name()) {
entityLabel = preset.name();
} else {
entityLabel = utilDisplayType(entity.id)
}
}
warnings.push({
id: 'disconnected_highway',
message: t('validations.disconnected_highway'),
message: t('validations.disconnected_highway', {entityLabel: entityLabel}),
tooltip: t('validations.disconnected_highway_tooltip'),
entity: entity
});