diff --git a/css/80_app.css b/css/80_app.css index 02a5dd97f..5c49520f9 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -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; diff --git a/data/core.yaml b/data/core.yaml index 88994e0eb..2ebc5ea43 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -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. diff --git a/dist/locales/en.json b/dist/locales/en.json index d066cd3d7..9c24bb8af 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -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.", diff --git a/modules/core/history.js b/modules/core/history.js index 16df09ae1..feb496362 100644 --- a/modules/core/history.js +++ b/modules/core/history.js @@ -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); }, diff --git a/modules/ui/background.js b/modules/ui/background.js index 4c30049ee..91a5e8300 100644 --- a/modules/ui/background.js +++ b/modules/ui/background.js @@ -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') diff --git a/modules/ui/issues.js b/modules/ui/issues.js index de618107c..ae6efa7a6 100644 --- a/modules/ui/issues.js +++ b/modules/ui/issues.js @@ -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'; diff --git a/modules/ui/map_data.js b/modules/ui/map_data.js index 7d90812b0..0d4793224 100644 --- a/modules/ui/map_data.js +++ b/modules/ui/map_data.js @@ -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) { diff --git a/modules/validations/issue_manager.js b/modules/validations/issue_manager.js index 982aa1261..3924ea125 100644 --- a/modules/validations/issue_manager.js +++ b/modules/validations/issue_manager.js @@ -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); } diff --git a/modules/validations/many_deletions.js b/modules/validations/many_deletions.js index 580d31e8f..01420ba4c 100644 --- a/modules/validations/many_deletions.js +++ b/modules/validations/many_deletions.js @@ -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; }; diff --git a/modules/validations/validation_issue.js b/modules/validations/validation_issue.js index 91e1ff3f1..7cae7c91a 100644 --- a/modules/validations/validation_issue.js +++ b/modules/validations/validation_issue.js @@ -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; }