updated: hacky note hovering; todo: complete note click handling

This commit is contained in:
Thomas Hervey
2018-07-02 10:44:47 -04:00
parent 5b4dde0004
commit 2c22fe00a2
4 changed files with 38 additions and 66 deletions
+16 -20
View File
@@ -3,24 +3,16 @@ import { uiFeatureList } from './feature_list';
import { uiInspector } from './inspector';
import { uiNoteEditor } from './note_editor';
import {
osmNote
} from '../osm';
export function uiSidebar(context) {
var inspector = uiInspector(context),
noteEditor = uiNoteEditor(context),
current,
wasNote;
function isNote(id) {
var isNote = (id && id.slice(0,4) === 'note') ? id.slice(0,4) : null;
// TODO: have a better check, perhaps see if the hover class is activated on a note
if (!isNote && wasNote) {
wasNote = false;
sidebar.hide();
} else if (isNote) {
wasNote = true;
sidebar.show(noteEditor);
}
}
wasNote = false;
function sidebar(selection) {
var featureListWrap = selection
@@ -34,10 +26,12 @@ export function uiSidebar(context) {
.attr('class', 'inspector-hidden inspector-wrap fr');
function hover(id) {
// isNote(id); TODO: instantiate check if needed
if (!current && context.hasEntity(id)) {
function hover(what) {
if ((what instanceof osmNote)) {
wasNote = true;
context.ui().sidebar.show(noteEditor, what);
}
else if (!current && context.hasEntity(what)) {
featureListWrap
.classed('inspector-hidden', true);
@@ -45,10 +39,10 @@ export function uiSidebar(context) {
.classed('inspector-hidden', false)
.classed('inspector-hover', true);
if (inspector.entityID() !== id || inspector.state() !== 'hover') {
if (inspector.entityID() !== what || inspector.state() !== 'hover') {
inspector
.state('hover')
.entityID(id);
.entityID(what);
inspectorWrap
.call(inspector);
@@ -61,8 +55,10 @@ export function uiSidebar(context) {
.classed('inspector-hidden', true);
inspector
.state('hide');
} else if (wasNote) {
wasNote = false;
context.ui().sidebar.hide();
}
// } // TODO: - remove if note check logic is moved
}