Skip to content

Commit

Permalink
Add "zoom to this" quicklink and keybind for keepright editor
Browse files Browse the repository at this point in the history
(re #5169)
  • Loading branch information
bhousel committed Jan 10, 2019
1 parent 9282a51 commit 98c08a0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 19 deletions.
1 change: 1 addition & 0 deletions css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
46 changes: 29 additions & 17 deletions modules/modes/select_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
};


Expand Down
27 changes: 25 additions & 2 deletions modules/ui/keepRight_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,41 @@ 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';


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]);

Expand Down Expand Up @@ -46,14 +68,15 @@ 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()
.append('div')
.attr('class', 'modal-section keepRight-editor')
.merge(editor)
.call(keepRightHeader.error(_error))
.call(quickLinks.choices(choices))
.call(keepRightDetails.error(_error))
.call(keepRightSaveSection);

Expand Down

0 comments on commit 98c08a0

Please sign in to comment.