From 896ed762e08c71eb93e1e5d8697818f405dd4d1f Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 30 Dec 2019 16:20:54 +0000 Subject: [PATCH] Fix silent failure for some Osmose error types When I added special handling for mapillary errors the code was trying to access translation strings nested under the error category (which doesn't exist for all error types). This code is now moved into it's own function so that variable hoisting doesn't run it for non-applicable error types and prevent them from working. - Also adds support for error type 3040 (bad tag value) - Updated the Osmose sidebar UI title --- css/65_data.css | 1 + data/core.yaml | 7 +++++-- data/qa_errors.json | 5 ++++- dist/locales/en.json | 8 ++++++-- modules/services/osmose.js | 21 +++++++++++++++++---- svg/fontawesome/far-times-circle.svg | 1 + 6 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 svg/fontawesome/far-times-circle.svg diff --git a/css/65_data.css b/css/65_data.css index 416321186..146adde24 100644 --- a/css/65_data.css +++ b/css/65_data.css @@ -169,6 +169,7 @@ color: #DCB000; } +.osmose.category-3040, .osmose.category-3161, .osmose.category-3250 { color: #2D9359; diff --git a/data/core.yaml b/data/core.yaml index 8939c3b29..44f12d4d6 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -828,7 +828,7 @@ en: full_screen: Toggle Full Screen QA: osmose: - title: Osmose + title: Osmose Issue error_types: 0: title: 'Building Intersection' @@ -863,6 +863,9 @@ en: 1280-1: title: 'Incorrect Speed Camera' description: '{0} should be on the highway or part of an "enforcement" relation.' + 3040-3040: + title: 'Unusual Tagging' + description: '{0} has a non-conventional tag value: {1}.' 3161: title: 'Missing Parking Access' description: 'There is no highway leading to {0}.' @@ -880,7 +883,7 @@ en: description: '{0} is a power tower or pole with no connected power lines.' 7040-4: title: 'Extra Power Line Node' - description: 'Power lines only have nodes at connections and {0} is not tagged as a power line support.' + description: 'Power lines should only have nodes at supports and {0} is not tagged as a pole or tower.' 8300: title: 'Traffic Sign Suggestion' description: 'Traffic signs detected by Mapillary suggest there may be an unmapped {0} nearby.' diff --git a/data/qa_errors.json b/data/qa_errors.json index 54eed409b..ddf8e3507 100644 --- a/data/qa_errors.json +++ b/data/qa_errors.json @@ -34,7 +34,7 @@ } }, "osmose": { - "items": ["0", "1040", "1050", "1070", "1150", "1280", "3161", "3250", "4080", "7040", "8300", "8360"], + "items": ["0", "1040", "1050", "1070", "1150", "1280", "3040", "3161", "3250", "4080", "7040", "8300", "8360"], "errorTypes": { "0-1": { "icon": "maki-home" @@ -78,6 +78,9 @@ "1280-1": { "icon": "maki-attraction" }, + "3040-3040": { + "icon": "far-times-circle" + }, "3161-1": { "icon": "maki-parking" }, diff --git a/dist/locales/en.json b/dist/locales/en.json index 535db8a62..60ff1331e 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1032,7 +1032,7 @@ "full_screen": "Toggle Full Screen", "QA": { "osmose": { - "title": "Osmose", + "title": "Osmose Issue", "error_types": { "0": { "title": "Building Intersection", @@ -1112,6 +1112,10 @@ "title": "Incorrect Speed Camera", "description": "{0} should be on the highway or part of an \"enforcement\" relation." }, + "3040-3040": { + "title": "Unusual Tagging", + "description": "{0} has a non-conventional tag value: {1}." + }, "3250-32501": { "title": "Invalid Opening Hours", "description": "{0} has an invalid value for the \"opening_hours\" tag." @@ -1122,7 +1126,7 @@ }, "7040-4": { "title": "Extra Power Line Node", - "description": "Power lines only have nodes at connections and {0} is not tagged as a power line support." + "description": "Power lines should only have nodes at supports and {0} is not tagged as a pole or tower." } } }, diff --git a/modules/services/osmose.js b/modules/services/osmose.js index b98c43df7..46f498ecf 100644 --- a/modules/services/osmose.js +++ b/modules/services/osmose.js @@ -144,13 +144,10 @@ export default { // Special handling for some error types // Setting elems here prevents UI error detail requests - var parts = dataEn.QA.osmose.error_types[d.item].parts; switch (d.item) { case 8300: case 8360: - // todo: possible to add link to open mapillay photo overlay? - d.replacements = [parts[d.class]]; - d.elems = []; + mapillaryError(d); break; } @@ -167,6 +164,13 @@ export default { _erCache.loadedTile[tile.id] = true; }); }); + + function mapillaryError(d) { + // Parts only exists for these error types + var parts = dataEn.QA.osmose.error_types[d.item].parts; + d.replacements = [parts[d.class]]; + d.elems = []; + } }, loadErrorDetail: function(d, callback) { @@ -192,6 +196,15 @@ export default { return linkEntity(i); }); + // Special handling for some error types + switch (d.item) { + case 3040: + d.replacements.push(/Bad value for (.+)/i + .exec(data.subtitle)[1] + ); + break; + } + that.replaceError(d); if (callback) callback(null, d); }) diff --git a/svg/fontawesome/far-times-circle.svg b/svg/fontawesome/far-times-circle.svg new file mode 100644 index 000000000..25b42d56e --- /dev/null +++ b/svg/fontawesome/far-times-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file