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
+1 -1
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);
}));
},
+12 -2
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
});