diff --git a/css/80_app.css b/css/80_app.css index 06066938f..1f6e116dc 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -1166,6 +1166,7 @@ img.tag-reference-wiki-image { } .data-editor .quick-links, +.keepRight-editor .quick-links, .note-editor .quick-links { padding: 5px 0 0 0; } diff --git a/modules/modes/select_error.js b/modules/modes/select_error.js index abd6ea8bf..aa0c8ef3b 100644 --- a/modules/modes/select_error.js +++ b/modules/modes/select_error.js @@ -10,6 +10,7 @@ import { behaviorSelect } from '../behavior'; +import { t } from '../util/locale'; import { services } from '../services'; import { modeBrowse, modeDragNode, modeDragNote } from '../modes'; import { uiKeepRightEditor } from '../ui'; @@ -53,7 +54,35 @@ export function modeSelectError(context, selectedErrorID) { } + mode.zoomToSelected = function() { + if (!keepRight) return; + var error = keepRight.getError(selectedErrorID); + if (error) { + context.map().centerZoom(error.loc, 20); + } + }; + + mode.enter = function() { + var error = checkSelectedID(); + if (!error) return; + + behaviors.forEach(context.install); + keybinding + .on(t('inspector.zoom_to.key'), mode.zoomToSelected) + .on('⎋', esc, true); + + d3_select(document) + .call(keybinding); + + selectError(); + + var sidebar = context.ui().sidebar; + sidebar.show(keepRightEditor.error(error)); + + context.map() + .on('drawn.select-error', selectError); + // class the error as selected, or return to browse mode if the error is gone function selectError(drawn) { @@ -82,23 +111,6 @@ export function modeSelectError(context, selectedErrorID) { if (d3_select('.combobox').size()) return; context.enter(modeBrowse(context)); } - - var error = checkSelectedID(); - if (!error) return; - - behaviors.forEach(context.install); - keybinding.on('⎋', esc, true); - - d3_select(document) - .call(keybinding); - - selectError(); - - var sidebar = context.ui().sidebar; - sidebar.show(keepRightEditor.error(error)); - - context.map() - .on('drawn.select-error', selectError); }; diff --git a/modules/ui/keepRight_editor.js b/modules/ui/keepRight_editor.js index 532c8c3e2..ca502b1e1 100644 --- a/modules/ui/keepRight_editor.js +++ b/modules/ui/keepRight_editor.js @@ -5,7 +5,15 @@ import { t } from '../util/locale'; import { services } from '../services'; import { modeBrowse } from '../modes'; import { svgIcon } from '../svg'; -import { uiKeepRightDetails, uiKeepRightHeader, uiViewOnKeepRight } from './index'; + +import { + uiKeepRightDetails, + uiKeepRightHeader, + uiQuickLinks, + uiTooltipHtml, + uiViewOnKeepRight +} from './index'; + import { utilNoAuto, utilRebind } from '../util'; @@ -13,11 +21,25 @@ export function uiKeepRightEditor(context) { var dispatch = d3_dispatch('change'); var keepRightDetails = uiKeepRightDetails(context); var keepRightHeader = uiKeepRightHeader(context); + var quickLinks = uiQuickLinks(); var _error; function keepRightEditor(selection) { + // quick links + var choices = [{ + id: 'zoom_to', + label: 'inspector.zoom_to.title', + tooltip: function() { + return uiTooltipHtml(t('inspector.zoom_to.tooltip_issue'), t('inspector.zoom_to.key')); + }, + click: function zoomTo() { + context.mode().zoomToSelected(); + } + }]; + + var header = selection.selectAll('.header') .data([0]); @@ -46,7 +68,7 @@ export function uiKeepRightEditor(context) { .attr('class', 'body') .merge(body); - var editor = body.selectAll('.error-editor') + var editor = body.selectAll('.keepRight-editor') .data([0]); editor.enter() @@ -54,6 +76,7 @@ export function uiKeepRightEditor(context) { .attr('class', 'modal-section keepRight-editor') .merge(editor) .call(keepRightHeader.error(_error)) + .call(quickLinks.choices(choices)) .call(keepRightDetails.error(_error)) .call(keepRightSaveSection);