mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 19:31:41 +00:00
Add different messages for no tags vs. no descriptive tags warnings
Add warning for relation without a "type" tag
This commit is contained in:
@@ -1228,7 +1228,12 @@ en:
|
||||
message: "Deleting {n} features: {p} points, {l} lines, {a} areas, and {r} relations."
|
||||
tip: Only redundant or nonexistent features should be deleted.
|
||||
missing_tag:
|
||||
message: "{feature} has no descriptive tags."
|
||||
any:
|
||||
message: "{feature} has no tags."
|
||||
descriptive:
|
||||
message: "{feature} has no descriptive tags."
|
||||
specific:
|
||||
message: '{feature} has no "{tag}" tag.'
|
||||
tip: Features must have tags that define what they are.
|
||||
old_multipolygon:
|
||||
message: "{multipolygon} has misplaced tags."
|
||||
|
||||
10
dist/locales/en.json
vendored
10
dist/locales/en.json
vendored
@@ -1503,7 +1503,15 @@
|
||||
"tip": "Only redundant or nonexistent features should be deleted."
|
||||
},
|
||||
"missing_tag": {
|
||||
"message": "{feature} has no descriptive tags.",
|
||||
"any": {
|
||||
"message": "{feature} has no tags."
|
||||
},
|
||||
"descriptive": {
|
||||
"message": "{feature} has no descriptive tags."
|
||||
},
|
||||
"specific": {
|
||||
"message": "{feature} has no \"{tag}\" tag."
|
||||
},
|
||||
"tip": "Features must have tags that define what they are."
|
||||
},
|
||||
"old_multipolygon": {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user