Merge pull request #4751 from bencostamagna/delete_warning

Warning on multiple deletions: added some details.
This commit is contained in:
Bryan Housel
2018-01-29 08:58:51 -05:00
committed by GitHub
3 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -536,7 +536,7 @@ en:
untagged_area_tooltip: "Select a feature type that describes what this area is."
untagged_relation: Untagged relation
untagged_relation_tooltip: "Select a feature type that describes what this relation is."
many_deletions: "You're deleting {n} features. Are you sure you want to do this? This will delete them from the map that everyone else sees on openstreetmap.org."
many_deletions: "You're deleting {n} features: {p} nodes, {l} lines, {a} areas, {r} relations. Are you sure you want to do this? This will delete them from the map that everyone else sees on openstreetmap.org."
tag_suggests_area: "The tag {tag} suggests line should be area, but it is not an area"
deprecated_tags: "Deprecated tags: {tags}"
zoom:
+1 -1
View File
@@ -655,7 +655,7 @@
"untagged_area_tooltip": "Select a feature type that describes what this area is.",
"untagged_relation": "Untagged relation",
"untagged_relation_tooltip": "Select a feature type that describes what this relation is.",
"many_deletions": "You're deleting {n} features. Are you sure you want to do this? This will delete them from the map that everyone else sees on openstreetmap.org.",
"many_deletions": "You're deleting {n} features: {p} nodes, {l} lines, {a} areas, {r} relations. Are you sure you want to do this? This will delete them from the map that everyone else sees on openstreetmap.org.",
"tag_suggests_area": "The tag {tag} suggests line should be area, but it is not an area",
"deprecated_tags": "Deprecated tags: {tags}"
},
+11 -2
View File
@@ -4,12 +4,21 @@ import { t } from '../util/locale';
export function validationManyDeletions() {
var threshold = 100;
var validation = function(changes) {
var validation = function(changes, graph) {
var warnings = [];
var nodes=0, ways=0, areas=0, relations=0;
changes.deleted.forEach(function(c) {
if (c.type === 'node') {nodes++;}
else if (c.type === 'way' && c.geometry(graph) === 'line') {ways++;}
else if (c.type === 'way' && c.geometry(graph) === 'area') {areas++;}
else if (c.type === 'relation') {relations++;}
});
if (changes.deleted.length > threshold) {
warnings.push({
id: 'many_deletions',
message: t('validations.many_deletions', { n: changes.deleted.length })
message: t('validations.many_deletions',
{ n: changes.deleted.length, p: nodes, l: ways, a:areas, r: relations })
});
}