mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
Restore many deletions warning with tooltip and nicer message
Add tooltips back to issues pane list Fix crash when restoring without having loaded the edited area
This commit is contained in:
+1
-2
@@ -2818,8 +2818,7 @@ div.full-screen > button:hover {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.layer-list li {
|
||||
position: relative;
|
||||
.layer-list > li {
|
||||
height: 30px;
|
||||
background-color: #fff;
|
||||
color: #7092ff;
|
||||
|
||||
+2
-1
@@ -1161,7 +1161,8 @@ en:
|
||||
message: "{feature} has no descriptive tags."
|
||||
tip: Features must have tags that define what they are.
|
||||
many_deletions:
|
||||
message: "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."
|
||||
message: "Deleting {n} features: {p} nodes, {l} lines, {a} areas, and {r} relations."
|
||||
tip: Only redundant or nonexistent features should be deleted.
|
||||
tag_suggests_area:
|
||||
message: 'Feature is a line, but the tag "{tag}" suggests it should be an area.'
|
||||
tip: Areas must have connected endpoints.
|
||||
|
||||
Vendored
+2
-1
@@ -1408,7 +1408,8 @@
|
||||
"tip": "Features must have tags that define what they are."
|
||||
},
|
||||
"many_deletions": {
|
||||
"message": "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."
|
||||
"message": "Deleting {n} features: {p} nodes, {l} lines, {a} areas, and {r} relations.",
|
||||
"tip": "Only redundant or nonexistent features should be deleted."
|
||||
},
|
||||
"tag_suggests_area": {
|
||||
"message": "Feature is a line, but the tag \"{tag}\" suggests it should be an area.",
|
||||
|
||||
+2
-13
@@ -18,7 +18,6 @@ import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
import { easeLinear as d3_easeLinear } from 'd3-ease';
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
|
||||
import * as Validations from '../validations/index';
|
||||
import { coreDifference } from './difference';
|
||||
import { coreGraph } from './graph';
|
||||
import { coreTree } from './tree';
|
||||
@@ -40,7 +39,6 @@ export function coreHistory(context) {
|
||||
var _stack;
|
||||
var _index;
|
||||
var _tree;
|
||||
var validations = _filter(Validations, _isFunction);
|
||||
|
||||
|
||||
// internal _act, accepts list of actions and eased time
|
||||
@@ -294,16 +292,6 @@ export function coreHistory(context) {
|
||||
},
|
||||
|
||||
|
||||
validate: function(entitiesToCheck) {
|
||||
return _flatten(_map(
|
||||
validations,
|
||||
function(fn) {
|
||||
return fn(context)(entitiesToCheck, _stack[_index].graph, _tree);
|
||||
}
|
||||
));
|
||||
},
|
||||
|
||||
|
||||
hasChanges: function() {
|
||||
return this.difference().length() > 0;
|
||||
},
|
||||
@@ -529,6 +517,7 @@ export function coreHistory(context) {
|
||||
loading.close();
|
||||
context.redrawEnable(true);
|
||||
dispatch.call('change');
|
||||
dispatch.call('restore', this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -583,6 +572,7 @@ export function coreHistory(context) {
|
||||
|
||||
if (loadComplete) {
|
||||
dispatch.call('change');
|
||||
dispatch.call('restore', this);
|
||||
}
|
||||
|
||||
return history;
|
||||
@@ -625,7 +615,6 @@ export function coreHistory(context) {
|
||||
|
||||
var json = context.storage(getKey('saved_history'));
|
||||
if (json) history.fromJSON(json, true);
|
||||
dispatch.call('restore', this);
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,6 @@ export function uiBackground(context) {
|
||||
|
||||
var enter = layerLinks.enter()
|
||||
.append('li')
|
||||
.attr('class', 'layer')
|
||||
.classed('layer-custom', function(d) { return d.id === 'custom'; })
|
||||
.classed('best', function(d) { return d.best(); });
|
||||
|
||||
@@ -218,7 +217,7 @@ export function uiBackground(context) {
|
||||
.append('ul')
|
||||
.attr('class', 'layer-list minimap-toggle-list')
|
||||
.append('li')
|
||||
.attr('class', 'layer minimap-toggle-item');
|
||||
.attr('class', 'minimap-toggle-item');
|
||||
|
||||
var minimapLabelEnter = minimapEnter
|
||||
.append('label')
|
||||
|
||||
+10
-11
@@ -66,7 +66,6 @@ export function uiIssues(context) {
|
||||
// Enter
|
||||
var enter = items.enter()
|
||||
.append('li')
|
||||
.attr('class', 'layer')
|
||||
.call(tooltip()
|
||||
.html(true)
|
||||
.title(function(d) {
|
||||
@@ -124,16 +123,8 @@ export function uiIssues(context) {
|
||||
var enter = items.enter()
|
||||
.append('li')
|
||||
.attr('class', function (d) {
|
||||
return 'layer issue severity-' + d.severity;
|
||||
return 'issue severity-' + d.severity;
|
||||
})
|
||||
.call(tooltip()
|
||||
.html(true)
|
||||
.title(function(d) {
|
||||
var tip = d.tooltip ? d.tooltip : '';
|
||||
return uiTooltipHtml(tip);
|
||||
})
|
||||
.placement('bottom')
|
||||
)
|
||||
.on('click', function(d) {
|
||||
var loc = d.loc();
|
||||
if (loc) {
|
||||
@@ -149,7 +140,15 @@ export function uiIssues(context) {
|
||||
|
||||
var label = enter
|
||||
.append('button')
|
||||
.attr('class', 'label');
|
||||
.attr('class', 'label')
|
||||
.call(tooltip()
|
||||
.html(true)
|
||||
.title(function(d) {
|
||||
var tip = d.tooltip ? d.tooltip : '';
|
||||
return uiTooltipHtml(tip);
|
||||
})
|
||||
.placement('bottom')
|
||||
);
|
||||
|
||||
label.each(function(d) {
|
||||
var iconSuffix = d.severity === 'warning' ? 'alert' : 'error';
|
||||
|
||||
@@ -495,7 +495,6 @@ export function uiMapData(context) {
|
||||
// Enter
|
||||
var enter = items.enter()
|
||||
.append('li')
|
||||
.attr('class', 'layer')
|
||||
.call(tooltip()
|
||||
.html(true)
|
||||
.title(function(d) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
|
||||
import _map from 'lodash-es/map';
|
||||
import _flatten from 'lodash-es/flatten';
|
||||
import _flattenDeep from 'lodash-es/flattenDeep';
|
||||
import _uniq from 'lodash-es/uniq';
|
||||
import _uniqWith from 'lodash-es/uniqWith';
|
||||
|
||||
import { utilRebind } from '../util/rebind';
|
||||
import * as validations from '../validations/index';
|
||||
|
||||
export function IssueManager(context) {
|
||||
var dispatch = d3_dispatch('reload'),
|
||||
@@ -37,7 +39,7 @@ export function IssueManager(context) {
|
||||
};
|
||||
self.getErrors = function() {
|
||||
return issues.filter(function(issue) {
|
||||
return issue.severity === 'error';
|
||||
return issue.severity === 'error';
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,19 +49,45 @@ export function IssueManager(context) {
|
||||
}
|
||||
if (!issuesByEntityId[entityID]) {
|
||||
var entity = context.entity(entityID);
|
||||
issuesByEntityId[entityID] = context.history().validate([entity]);
|
||||
issuesByEntityId[entityID] = validateEntity(entity);
|
||||
}
|
||||
return issuesByEntityId[entityID];
|
||||
};
|
||||
|
||||
var entityValidations = [
|
||||
validations.validationDeprecatedTag,
|
||||
validations.validationDisconnectedHighway,
|
||||
validations.validationGenericName,
|
||||
validations.validationHighwayCrossingOtherWays,
|
||||
validations.validationHighwayAlmostJunction,
|
||||
validations.validationMapCSSChecks,
|
||||
validations.validationMissingTag,
|
||||
validations.validationOldMultipolygon,
|
||||
validations.validationTagSuggestsArea
|
||||
];
|
||||
|
||||
function validateEntity(entity) {
|
||||
var history = context.history();
|
||||
return _flatten(_map(
|
||||
entityValidations,
|
||||
function(fn) {
|
||||
return fn(context)([entity], history.graph(), history.tree());
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
self.validate = function() {
|
||||
// clear cached issues
|
||||
issuesByEntityId = {};
|
||||
issues = [];
|
||||
|
||||
var changes = context.history().changes();
|
||||
var history = context.history();
|
||||
var changes = history.changes();
|
||||
var entitiesToCheck = changes.created.concat(changes.modified);
|
||||
var graph = context.graph();
|
||||
var graph = history.graph();
|
||||
|
||||
issues = issues.concat(validations.validationManyDeletions(context)(changes, graph));
|
||||
|
||||
entitiesToCheck = _uniq(_flattenDeep(_map(entitiesToCheck, function(entity) {
|
||||
var entities = [entity];
|
||||
if (entity.type === 'node') {
|
||||
@@ -78,7 +106,7 @@ export function IssueManager(context) {
|
||||
|
||||
for (var entityIndex in entitiesToCheck) {
|
||||
var entity = entitiesToCheck[entityIndex];
|
||||
var entityIssues = context.history().validate([entity]);
|
||||
var entityIssues = validateEntity(entity);
|
||||
issuesByEntityId[entity.id] = entityIssues;
|
||||
issues = issues.concat(entityIssues);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export function validationManyDeletions() {
|
||||
var validation = function(changes, graph) {
|
||||
var issues = [];
|
||||
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++; }
|
||||
@@ -26,9 +26,11 @@ export function validationManyDeletions() {
|
||||
'issues.many_deletions.message',
|
||||
{ n: changes.deleted.length, p: nodes, l: ways, a:areas, r: relations }
|
||||
),
|
||||
tooltip: t('issues.many_deletions.tip'),
|
||||
hash: [nodes, ways, areas, relations].join()
|
||||
}));
|
||||
}
|
||||
*/
|
||||
|
||||
return issues;
|
||||
};
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ export function validationIssue(attrs) {
|
||||
if (this.coordinates && Array.isArray(this.coordinates) && this.coordinates.length === 2) {
|
||||
return this.coordinates;
|
||||
}
|
||||
if (this.entities.length > 0) {
|
||||
if (this.entities && this.entities.length > 0) {
|
||||
if (this.entities[0].loc) {
|
||||
return this.entities[0].loc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user