Merge pull request #6302 from openstreetmap/text-raw-tag-editor

Text raw tag editor / Copy-paste tags
This commit is contained in:
Bryan Housel
2019-05-03 14:53:08 -04:00
committed by GitHub
11 changed files with 307 additions and 85 deletions
+4 -17
View File
@@ -3,7 +3,7 @@ import { actionChangePreset } from '../actions/change_preset';
import { actionChangeTags } from '../actions/change_tags';
import { actionUpgradeTags } from '../actions/upgrade_tags';
import { osmIsOldMultipolygonOuterMember, osmOldMultipolygonOuterMemberOfRelation } from '../osm/multipolygon';
import { utilArrayUnion, utilDisplayLabel } from '../util';
import { utilDisplayLabel, utilTagDiff } from '../util';
import { validationIssue, validationIssueFix } from '../core/validation';
@@ -48,20 +48,7 @@ export function validationOutdatedTags() {
}
// determine diff
var keys = utilArrayUnion(Object.keys(oldTags), Object.keys(newTags)).sort();
var tagDiff = [];
keys.forEach(function(k) {
var oldVal = oldTags[k];
var newVal = newTags[k];
if (oldVal && (!newVal || newVal !== oldVal)) {
tagDiff.push('- ' + k + '=' + oldVal);
}
if (newVal && (!oldVal || newVal !== oldVal)) {
tagDiff.push('+ ' + k + '=' + newVal);
}
});
var tagDiff = utilTagDiff(oldTags, newTags);
if (!tagDiff.length) return [];
return [new validationIssue({
@@ -113,10 +100,10 @@ export function validationOutdatedTags() {
.attr('class', 'tagDiff-row')
.append('td')
.attr('class', function(d) {
var klass = d.charAt(0) === '+' ? 'add' : 'remove';
var klass = d.type === '+' ? 'add' : 'remove';
return 'tagDiff-cell tagDiff-cell-' + klass;
})
.text(function(d) { return d; });
.text(function(d) { return d.display; });
}
}
+6 -9
View File
@@ -1,6 +1,6 @@
import { actionChangeTags } from '../actions/change_tags';
import { t } from '../util/locale';
import { utilDisplayLabel } from '../util';
import { utilDisplayLabel, utilTagDiff } from '../util';
import { validationIssue, validationIssueFix } from '../core/validation';
@@ -40,20 +40,17 @@ export function validationPrivateData() {
var validation = function checkPrivateData(entity, context) {
var tags = entity.tags;
var keepTags = {};
var tagDiff = [];
if (!tags.building || !privateBuildingValues[tags.building]) return [];
var keepTags = {};
for (var k in tags) {
if (publicKeys[k]) return []; // probably a public feature
if (personalTags[k]) {
tagDiff.push('- ' + k + '=' + tags[k]);
} else {
if (!personalTags[k]) {
keepTags[k] = tags[k];
}
}
var tagDiff = utilTagDiff(tags, keepTags);
if (!tagDiff.length) return [];
var fixID = tagDiff.length === 1 ? 'remove_tag' : 'remove_tags';
@@ -110,10 +107,10 @@ export function validationPrivateData() {
.attr('class', 'tagDiff-row')
.append('td')
.attr('class', function(d) {
var klass = d.charAt(0) === '+' ? 'add' : 'remove';
var klass = d.type === '+' ? 'add' : 'remove';
return 'tagDiff-cell tagDiff-cell-' + klass;
})
.text(function(d) { return d; });
.text(function(d) { return d.display; });
}
};