diff --git a/css/65_data.css b/css/65_data.css index af60c2b66..ba85cc533 100644 --- a/css/65_data.css +++ b/css/65_data.css @@ -337,13 +337,14 @@ color: #b07f7e; } -.kr_error-details-description { +.kr_error-details-title { text-align: left; margin-bottom: 20px; } .kr_error-details-description { text-align: left; + margin-bottom: 10px; } .QA-buttons { diff --git a/data/core.yaml b/data/core.yaml index 2d2eeb0b9..55b4a3286 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -665,6 +665,10 @@ en: node: node way: way relation: relation + highway: highway + cycleway: cycleway + waterway: waterway + riverbank: riverbank errorTypes: errors: _30: @@ -689,10 +693,10 @@ en: description: 'missing tags' tooltip: 'This {var1} has an empty tag: {var2}' _71: - description: '' + description: 'way without tags' tooltip: 'This way has no tags' _72: - description: '' + description: 'node without tags' tooltip: 'This node is not member of any way and doesn''t have any tags' _90: description: 'motorways without ref' diff --git a/dist/locales/en.json b/dist/locales/en.json index 24dfbfc72..60e6beaf6 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -803,7 +803,11 @@ "entities": { "node": "node", "way": "way", - "relation": "relation" + "relation": "relation", + "highway": "highway", + "cycleway": "cycleway", + "waterway": "waterway", + "riverbank": "riverbank" }, "errorTypes": { "errors": { @@ -836,11 +840,11 @@ "tooltip": "This {var1} has an empty tag: {var2}" }, "_71": { - "description": "", + "description": "way without tags", "tooltip": "This way has no tags" }, "_72": { - "description": "", + "description": "node without tags", "tooltip": "This node is not member of any way and doesn't have any tags" }, "_90": { diff --git a/modules/ui/keepRight_details.js b/modules/ui/keepRight_details.js index 646609b61..ead79998e 100644 --- a/modules/ui/keepRight_details.js +++ b/modules/ui/keepRight_details.js @@ -1,8 +1,9 @@ import { t } from '../util/locale'; import { parseErrorDescriptions, errorTypes } from '../util'; +import { select as d3_select } from 'd3-selection'; -export function uiKeepRightDetails() { +export function uiKeepRightDetails(context) { var _error; var _template; var _templateErrorType; @@ -11,6 +12,8 @@ export function uiKeepRightDetails() { var _parent_error_type = ''; var _titleBase; + var _links; + function initDetails() { if (errorTypes.errors['_' + _error.error_type]) { @@ -18,7 +21,7 @@ export function uiKeepRightDetails() { _template = errorTypes.errors[_templateErrorType]; _category = 'errors'; } else if (errorTypes.warnings[_templateErrorType]) { - _template = errorTypes.errors[_templateErrorType]; + _template = errorTypes.warnings[_templateErrorType]; _category = 'warnings'; } else { return; } @@ -54,6 +57,7 @@ export function uiKeepRightDetails() { .append('div') .attr('class', 'kr_error-details kr_error-details-container'); + // title var title = detailsEnter .append('div') @@ -68,7 +72,7 @@ export function uiKeepRightDetails() { // if this is a subtype, append it's parent title if (_parent_error_type) { - title = t(_titleBase + _parent_error_type + '.description' + ':\n'); + title = t(_titleBase + _parent_error_type + '.description') + ':\n'; } // append title @@ -79,6 +83,7 @@ export function uiKeepRightDetails() { return title; }); + // description var description = detailsEnter .append('div') @@ -90,9 +95,18 @@ export function uiKeepRightDetails() { description .append('div') + .attr('class', 'kr_error-details-description-text') .text(function(d) { return t(_titleBase + _templateErrorType + '.tooltip', parseErrorDescriptions(d)); }); + + // TODO: add links to ids in description + // d3_select('.kr_error-details-description-text').enter() + // .append('span') + // .append('a') + // .text(function(d) { return d.object_id; }) + // .on('click', function() { console.log('hi'); }); + } diff --git a/modules/ui/keepRight_editor.js b/modules/ui/keepRight_editor.js index 9002dc4ba..18319539a 100644 --- a/modules/ui/keepRight_editor.js +++ b/modules/ui/keepRight_editor.js @@ -25,7 +25,7 @@ import { export function uiKeepRightEditor(context) { var dispatch = d3_dispatch('change'); var keepRightComment = uiKeepRightComment(); - var keepRightDetails = uiKeepRightDetails(); + var keepRightDetails = uiKeepRightDetails(context); var keepRightHeader = uiKeepRightHeader(context); var _error; diff --git a/modules/ui/keepRight_header.js b/modules/ui/keepRight_header.js index a40fdc96e..770c9be40 100644 --- a/modules/ui/keepRight_header.js +++ b/modules/ui/keepRight_header.js @@ -1,14 +1,44 @@ import { t } from '../util/locale'; import { svgIcon } from '../svg'; +import { event as d3_event } from 'd3-selection'; +import { geoChooseEdge } from '../geo'; +import { modeSelect } from '../modes'; export function uiKeepRightHeader(context) { var _error; - function getEntityLink() { + function clickLink() { + var d = {}; - var url = context.connection().entityURL(context.entity(_error.object_id)); + var entityType = + _error.object_type === 'node' ? 'n' : + _error.object_type === 'way' ? 'w' : + _error.object_type === 'relation' ? 'r' : null; + + // if an entity has been loaded in the graph, select the entity + if (context.hasEntity(entityType + _error.object_id)) { + d = context.hasEntity(entityType + _error.object_id); + } + + d3_event.preventDefault(); + if (d.location) { + context.map().centerZoom([d.location[1], d.location[0]], 19); + } + else if (d.entity) { + if (d.entity.type === 'node') { + context.map().center(d.entity.loc); + } else if (d.entity.type === 'way') { + var center = context.projection(context.map().center()); + var edge = geoChooseEdge(context.childNodes(d.entity), center, context.projection); + context.map().center(edge.loc); + } + context.enter(modeSelect(context, [d.entity.id])); + } else { + // TODO: turn on osm layer + context.zoomToEntity(d.id); + } } @@ -42,12 +72,11 @@ export function uiKeepRightHeader(context) { headerEnter .append('div') .attr('class', 'kr_error-header-label') - .text(function(d) { - return t('keepRight.entities.' + d.object_type + ' '); - }) + .text(function(d) { return t('keepRight.entities.' + d.object_type) + ' '; }) .append('span') - // .attr('href', getEntityLink()) // TODO: add / remove link if entity is/isn't in the graph - .text(function(d) { return d.object_id; }); + .append('a') + .text(function(d) { return d.object_id; }) + .on('click', clickLink); } diff --git a/modules/ui/map_data.js b/modules/ui/map_data.js index 1132957c2..429fa4f16 100644 --- a/modules/ui/map_data.js +++ b/modules/ui/map_data.js @@ -722,7 +722,7 @@ export function uiMapData(context) { // context.errors() // .on('change.map_data-update', update); // TODO: add errors list to context? - +'' update(); setFill(_fillSelected); diff --git a/modules/util/keepRight/keepRight_error.js b/modules/util/keepRight/keepRight_error.js index 683b0ebee..c9a73047f 100644 --- a/modules/util/keepRight/keepRight_error.js +++ b/modules/util/keepRight/keepRight_error.js @@ -64,7 +64,7 @@ export function parseErrorDescriptions(entity) { var parsedDescriptions = []; var re = new RegExp(/{\$[0-9]}/); - var commonEntities = ['node', 'way', 'relation']; // TODO: expand this list, or implement a different translation function + var commonEntities = ['node', 'way', 'relation', 'highway', 'cycleway', 'waterway', 'riverbank']; // TODO: expand this list, or implement a different translation function templateDescriptions.forEach(function(word, index) { if (!re.test(word)) return;