mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
Added quick fix for tag_suggest_area validation to remove the suggesting tags
This commit is contained in:
@@ -1212,6 +1212,9 @@ en:
|
||||
remove_name:
|
||||
title: Remove the name
|
||||
undo_redo: Removed a generic name.
|
||||
remove_tags:
|
||||
title: Remove the tags
|
||||
undo_redo: Removed tags.
|
||||
move_tags:
|
||||
title: Move the tags
|
||||
undo_redo: Moved tags.
|
||||
|
||||
Vendored
+4
@@ -1482,6 +1482,10 @@
|
||||
"title": "Remove the name",
|
||||
"undo_redo": "Removed a generic name."
|
||||
},
|
||||
"remove_tags": {
|
||||
"title": "Remove the tags",
|
||||
"undo_redo": "Removed tags."
|
||||
},
|
||||
"move_tags": {
|
||||
"title": "Move the tags",
|
||||
"undo_redo": "Moved tags."
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import _isEmpty from 'lodash-es/isEmpty';
|
||||
import _clone from 'lodash-es/clone';
|
||||
import { t } from '../util/locale';
|
||||
import {
|
||||
utilTagText
|
||||
} from '../util';
|
||||
import {
|
||||
ValidationIssueType,
|
||||
ValidationIssueSeverity,
|
||||
validationIssue,
|
||||
validationIssueFix
|
||||
} from './validation_issue';
|
||||
import {
|
||||
actionChangeTags
|
||||
} from '../actions';
|
||||
|
||||
|
||||
// https://github.com/openstreetmap/josm/blob/mirror/src/org/
|
||||
@@ -14,18 +22,21 @@ export function validationTagSuggestsArea(context) {
|
||||
function tagSuggestsArea(tags) {
|
||||
if (_isEmpty(tags)) return false;
|
||||
|
||||
var presence = ['landuse', 'amenities', 'tourism', 'shop'];
|
||||
for (var i = 0; i < presence.length; i++) {
|
||||
if (tags[presence[i]] !== undefined) {
|
||||
if (presence[i] === 'tourism' && tags[presence[i]] === 'artwork') {
|
||||
var areaKeys = ['area', 'building', 'landuse', 'shop', 'tourism'];
|
||||
for (var i = 0; i < areaKeys.length; i++) {
|
||||
var key = areaKeys[i];
|
||||
if (tags[key] !== undefined && tags[key] !== 'no') {
|
||||
if (key === 'tourism' && tags[key] === 'artwork') {
|
||||
continue; // exception for tourism=artwork - #5206
|
||||
} else {
|
||||
return presence[i] + '=' + tags[presence[i]];
|
||||
var returnTags = {};
|
||||
returnTags[key] = tags[key];
|
||||
return returnTags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.building && tags.building === 'yes') return 'building=yes';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,15 +45,32 @@ export function validationTagSuggestsArea(context) {
|
||||
for (var i = 0; i < entitiesToCheck.length; i++) {
|
||||
var entity = entitiesToCheck[i];
|
||||
var geometry = entity.geometry(graph);
|
||||
var suggestion = (geometry === 'line' ? tagSuggestsArea(entity.tags) : undefined);
|
||||
var suggestingTags = (geometry === 'line' ? tagSuggestsArea(entity.tags) : undefined);
|
||||
|
||||
if (suggestion) {
|
||||
if (suggestingTags) {
|
||||
var tagText = utilTagText({ tags: suggestingTags });
|
||||
issues.push(new validationIssue({
|
||||
type: ValidationIssueType.tag_suggests_area,
|
||||
severity: ValidationIssueSeverity.warning,
|
||||
message: t('issues.tag_suggests_area.message', { tag: suggestion }),
|
||||
message: t('issues.tag_suggests_area.message', { tag: tagText }),
|
||||
tooltip: t('issues.tag_suggests_area.tip'),
|
||||
entities: [entity],
|
||||
fixes: [
|
||||
new validationIssueFix({
|
||||
title: t('issues.fix.remove_tags.title'),
|
||||
action: function() {
|
||||
var entity = this.issue.entities[0];
|
||||
var tags = _clone(entity.tags);
|
||||
for (var key in suggestingTags) {
|
||||
delete tags[key];
|
||||
}
|
||||
context.perform(
|
||||
actionChangeTags(entity.id, tags),
|
||||
t('issues.fix.remove_tags.undo_redo')
|
||||
);
|
||||
}
|
||||
})
|
||||
]
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user