Add different messages for no tags vs. no descriptive tags warnings

Add warning for relation without a "type" tag
This commit is contained in:
Quincy Morgan
2019-02-06 09:38:33 -05:00
parent 6383fa7ea0
commit 33d02cdba0
3 changed files with 66 additions and 32 deletions
+51 -30
View File
@@ -1,4 +1,5 @@
import _without from 'lodash-es/without';
import _isEmpty from 'lodash-es/isEmpty';
import { osmIsInterestingTag } from '../osm/tags';
import { t } from '../util/locale';
import {
@@ -23,39 +24,59 @@ export function validationMissingTag() {
var type = 'missing_tag';
var validation = function(entity, context) {
var types = ['point', 'line', 'area', 'relation'];
var issues = [];
var graph = context.graph();
var geometry = entity.geometry(graph);
// ignore vertex features
if (types.indexOf(geometry) !== -1 &&
!(hasDescriptiveTags(entity) || entity.hasParentRelations(graph))) {
var entityLabel = utilDisplayLabel(entity, context);
issues.push(new validationIssue({
type: type,
// error if created or modified, else warning
severity: !entity.version || entity.v ? 'error' : 'warning',
message: t('issues.missing_tag.message', { feature: entityLabel }),
tooltip: t('issues.missing_tag.tip'),
entities: [entity],
fixes: [
new validationIssueFix({
title: t('issues.fix.select_preset.title'),
onClick: function() {
context.ui().sidebar.showPresetList();
}
}),
new validationIssueFix({
title: t('issues.fix.delete_feature.title'),
onClick: function() {
var id = this.issue.entities[0].id;
operationDelete([id], context)();
}
})
]
}));
// ignore vertex features and relation members
if (entity.geometry(graph) === 'vertex' || entity.hasParentRelations(graph)) {
return [];
}
var messageObj = {}, missingTagType;
if (_isEmpty(entity.tags)) {
missingTagType = 'any';
} else if (!hasDescriptiveTags(entity)) {
missingTagType = 'descriptive';
} else if (entity.type === 'relation' && !entity.tags.type) {
missingTagType = 'specific';
messageObj.tag = 'type';
}
if (!missingTagType) {
return [];
}
messageObj.feature = utilDisplayLabel(entity, context);
var issues = [];
issues.push(new validationIssue({
type: type,
// error if created or modified, else warning
severity: !entity.version || entity.v ? 'error' : 'warning',
message: t('issues.missing_tag.'+missingTagType+'.message', messageObj),
tooltip: t('issues.missing_tag.tip'),
entities: [entity],
fixes: [
new validationIssueFix({
title: t('issues.fix.select_preset.title'),
onClick: function() {
context.ui().sidebar.showPresetList();
}
}),
new validationIssueFix({
title: t('issues.fix.delete_feature.title'),
onClick: function() {
var id = this.issue.entities[0].id;
operationDelete([id], context)();
}
})
]
}));
return issues;
};