diff --git a/data/core.yaml b/data/core.yaml index a4d725318..49f1c13a3 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -547,6 +547,7 @@ en: tooltip_issue: "Center and zoom the map to focus on this issue." show_more: Show More view_on_osm: View on openstreetmap.org + view_on_osmose: View on osmose.openstreetmap.fr view_on_keepRight: View on keepright.at feature_type: Feature Type fields: Fields diff --git a/dist/locales/en.json b/dist/locales/en.json index 40393cc6c..7a55d802e 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -692,6 +692,7 @@ }, "show_more": "Show More", "view_on_osm": "View on openstreetmap.org", + "view_on_osmose": "View on osmose.openstreetmap.fr", "view_on_keepRight": "View on keepright.at", "feature_type": "Feature Type", "fields": "Fields", diff --git a/modules/services/osmose.js b/modules/services/osmose.js index 0d03f2c62..5f4c8b0e5 100644 --- a/modules/services/osmose.js +++ b/modules/services/osmose.js @@ -333,5 +333,9 @@ export default { // Used to populate `closed:osmose:*` changeset tags getClosedCounts() { return _cache.closed; + }, + + itemURL(item) { + return `https://osmose.openstreetmap.fr/error/${item.id}`; } }; diff --git a/modules/ui/osmose_editor.js b/modules/ui/osmose_editor.js index 93df17386..b570e1f14 100644 --- a/modules/ui/osmose_editor.js +++ b/modules/ui/osmose_editor.js @@ -9,6 +9,7 @@ import { uiOsmoseDetails } from './osmose_details'; import { uiOsmoseHeader } from './osmose_header'; import { uiQuickLinks } from './quick_links'; import { uiTooltipHtml } from './tooltipHtml'; +import { uiViewOnOsmose } from './view_on_osmose'; import { utilRebind } from '../util'; @@ -65,6 +66,15 @@ export function uiOsmoseEditor(context) { .call(quickLinks.choices(choices)) .call(qaDetails.issue(_qaItem)) .call(osmoseSaveSection); + + const footer = selection.selectAll('.footer') + .data([0]); + + footer.enter() + .append('div') + .attr('class', 'footer') + .merge(footer) + .call(uiViewOnOsmose(context).what(_qaItem)); } function osmoseSaveSection(selection) { diff --git a/modules/ui/view_on_osmose.js b/modules/ui/view_on_osmose.js new file mode 100644 index 000000000..578d7d7a6 --- /dev/null +++ b/modules/ui/view_on_osmose.js @@ -0,0 +1,42 @@ +import { t } from '../util/locale'; +import { services } from '../services'; +import { svgIcon } from '../svg/icon'; +import { QAItem } from '../osm'; + +export function uiViewOnOsmose() { + let _qaItem; + + function viewOnOsmose(selection) { + let url; + if (services.osmose && (_qaItem instanceof QAItem)) { + url = services.osmose.itemURL(_qaItem); + } + + const link = selection.selectAll('.view-on-osmose') + .data(url ? [url] : []); + + // exit + link.exit() + .remove(); + + // enter + const linkEnter = link.enter() + .append('a') + .attr('class', 'view-on-osmose') + .attr('target', '_blank') + .attr('href', d => d) + .call(svgIcon('#iD-icon-out-link', 'inline')); + + linkEnter + .append('span') + .text(t('inspector.view_on_osmose')); + } + + viewOnOsmose.what = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return viewOnOsmose; + }; + + return viewOnOsmose; +}