diff --git a/data/core.yaml b/data/core.yaml index c9c0e9b5e..14d142bd2 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -676,15 +676,15 @@ en: description: 'This way is tagged with "{var1}={var2}" and should be a closed loop.' 40: title: 'Impossible oneways' - description: 'The first node ({var1}) of this oneway is not connected to any other way.' + description: 'The first node {var1} of this oneway is not connected to any other way.' 41: - description: 'The last node ({var1}) of this oneway is not connected to any other way.' + description: 'The last node {var1} of this oneway is not connected to any other way.' 42: description: 'You cannot reach this node because all ways leading from it are oneway.' 43: description: 'You cannot escape from this node because all ways leading to it are oneway.' 50: - title: 'Almost-junctions' + title: 'Almost junctions' description: 'This node is very close but not connected to way {var1}.' 60: title: 'Deprecated tags' @@ -792,7 +792,7 @@ en: description: '"from" and "to" members of turn restrictions need to be ways. {var1}.' 295: title: 'Restriction "via" is not on the way ends' - description: '"via" (node #{var1}) is not the first or the last member of "from" (way #{var2}).' + description: '"via" (node {var1}) is not the first or the last member of "from" (way {var2}).' 296: title: 'Wrong restriction angle' description: 'Restriction type is "{var1}" but angle is {var2} degrees. Maybe the restriction type is not appropriate?' @@ -828,7 +828,7 @@ en: description: 'It would be nice if this {var1} had an additional tag "name:XX"="{var2}" where XX shows the language of its name "{var2}".' 370: title: 'Doubled places' - description: 'This node has tags in common with the surrounding way #{var1} {var2} and seems to be redundant.' + description: 'This node has tags in common with the surrounding way {var1} {var2} and seems to be redundant.' 380: title: 'Non-physical use of sport tag' description: 'This way is tagged "sport={var1}" but has no physical tag (e.g. "leisure", "building", "amenity", or "highway".' diff --git a/dist/locales/en.json b/dist/locales/en.json index 89cb0b5c4..6b26bf07a 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -819,10 +819,10 @@ }, "40": { "title": "Impossible oneways", - "description": "The first node ({var1}) of this oneway is not connected to any other way." + "description": "The first node {var1} of this oneway is not connected to any other way." }, "41": { - "description": "The last node ({var1}) of this oneway is not connected to any other way." + "description": "The last node {var1} of this oneway is not connected to any other way." }, "42": { "description": "You cannot reach this node because all ways leading from it are oneway." @@ -831,7 +831,7 @@ "description": "You cannot escape from this node because all ways leading to it are oneway." }, "50": { - "title": "Almost-junctions", + "title": "Almost junctions", "description": "This node is very close but not connected to way {var1}." }, "60": { @@ -978,7 +978,7 @@ }, "295": { "title": "Restriction \"via\" is not on the way ends", - "description": "\"via\" (node #{var1}) is not the first or the last member of \"from\" (way #{var2})." + "description": "\"via\" (node {var1}) is not the first or the last member of \"from\" (way {var2})." }, "296": { "title": "Wrong restriction angle", @@ -1026,7 +1026,7 @@ }, "370": { "title": "Doubled places", - "description": "This node has tags in common with the surrounding way #{var1} {var2} and seems to be redundant." + "description": "This node has tags in common with the surrounding way {var1} {var2} and seems to be redundant." }, "380": { "title": "Non-physical use of sport tag", diff --git a/modules/ui/keepRight_details.js b/modules/ui/keepRight_details.js index 1b9b29981..a807b452f 100644 --- a/modules/ui/keepRight_details.js +++ b/modules/ui/keepRight_details.js @@ -6,24 +6,39 @@ import { t } from '../util/locale'; export function uiKeepRightDetails(context) { - var stringBase = 'QA.keepRight.errorTypes.'; var _error; - function keepRightDetails(selection) { - if (!_error) return; - var errorType = _error.error_type; + function errorDetail(d) { + var unknown = t('inspector.unknown'); + + if (!d) return unknown; + var errorType = d.error_type; + var template = errorTypes[errorType]; - if (!template) return; + if (!template) return unknown; // if there is a parent, save its error type e.g.: // Error 191 = "highway-highway" // Error 190 = "intersections without junctions" (parent) var parentErrorType = (Math.floor(errorType / 10) * 10).toString(); var parentTemplate = errorTypes[parentErrorType]; - if (!parentTemplate) return; + if (!parentTemplate) return unknown; + + var et = dataEn.QA.keepRight.errorTypes[errorType]; + var pt = dataEn.QA.keepRight.errorTypes[parentErrorType]; + + if (et && et.description) { + return t('QA.keepRight.errorTypes.' + errorType + '.description', d.replacements); + } else if (pt && pt.description) { + return t('QA.keepRight.errorTypes.' + parentErrorType + '.description', d.replacements); + } else { + return unknown; + } + } + function keepRightDetails(selection) { var details = selection.selectAll('.kr_error-details') .data( (_error ? [_error] : []), @@ -37,29 +52,6 @@ export function uiKeepRightDetails(context) { .append('div') .attr('class', 'kr_error-details kr_error-details-container'); - var titleEnter = detailsEnter - .append('div') - .attr('class', 'kr_error-details-title'); - - titleEnter - .append('h4') - .text(function() { return t('QA.keepRight.detail_title'); }); - - titleEnter - .append('div') - .text(function() { - var et = dataEn.QA.keepRight.errorTypes[errorType]; - var pt = dataEn.QA.keepRight.errorTypes[parentErrorType]; - - if (et && et.title) { - return t(stringBase + errorType + '.title'); - } else if (pt && pt.title) { - return t(stringBase + parentErrorType + '.title'); - } else { - return t('inspector.unknown'); - } - }); - // description var description = detailsEnter @@ -73,18 +65,7 @@ export function uiKeepRightDetails(context) { description .append('div') .attr('class', 'kr_error-details-description-text') - .html(function(d) { - var et = dataEn.QA.keepRight.errorTypes[errorType]; - var pt = dataEn.QA.keepRight.errorTypes[parentErrorType]; - - if (et && et.description) { - return t(stringBase + errorType + '.description', d.replacements); - } else if (pt && pt.description) { - return t(stringBase + parentErrorType + '.description', d.replacements); - } else { - return t('inspector.unknown'); - } - }); + .html(errorDetail); description.selectAll('.kr_error_description-id') .on('click', function() { clickLink(context, this.text); }); diff --git a/modules/ui/keepRight_header.js b/modules/ui/keepRight_header.js index 878eb588a..261bc0268 100644 --- a/modules/ui/keepRight_header.js +++ b/modules/ui/keepRight_header.js @@ -1,21 +1,54 @@ -import { t } from '../util/locale'; +import { dataEn } from '../../data'; +import { errorTypes } from '../../data/keepRight.json'; import { svgIcon } from '../svg'; +import { t } from '../util/locale'; export function uiKeepRightHeader() { var _error; + function errorTitle(d) { + var unknown = t('inspector.unknown'); + + if (!d) return unknown; + var errorType = d.error_type; + + var template = errorTypes[errorType]; + if (!template) return unknown; + + // if there is a parent, save its error type e.g.: + // Error 191 = "highway-highway" + // Error 190 = "intersections without junctions" (parent) + var parentErrorType = (Math.floor(errorType / 10) * 10).toString(); + var parentTemplate = errorTypes[parentErrorType]; + if (!parentTemplate) return unknown; + + var et = dataEn.QA.keepRight.errorTypes[errorType]; + var pt = dataEn.QA.keepRight.errorTypes[parentErrorType]; + + if (et && et.title) { + return t('QA.keepRight.errorTypes.' + errorType + '.title'); + } else if (pt && pt.title) { + return t('QA.keepRight.errorTypes.' + parentErrorType + '.title'); + } else { + return unknown; + } + } + + function keepRightHeader(selection) { var header = selection.selectAll('.kr_error-header') .data( (_error ? [_error] : []), - function(d) { return d.id; } + function(d) { return d.status + d.id; } ); header.exit() .remove(); + + var headerEnter = header.enter() .append('div') .attr('class', 'kr_error-header'); @@ -35,7 +68,7 @@ export function uiKeepRightHeader() { headerEnter .append('div') .attr('class', 'kr_error-header-label') - .text(function(d) { return t('QA.keepRight.entities.' + d.object_type, { id: d.object_id }); }); + .text(errorTitle); }