added new-note button

This commit is contained in:
Thomas Hervey
2018-07-17 11:35:27 -04:00
parent 73d0f30453
commit af2b67663b
11 changed files with 102 additions and 14 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ export function uiInit(context) {
limiter
.append('div')
.attr('class', 'button-wrap joined col3')
.attr('class', 'button-wrap joined col5')
.call(uiModes(context), limiter);
limiter
+20 -3
View File
@@ -3,10 +3,13 @@ import _debounce from 'lodash-es/debounce';
import { select as d3_select } from 'd3-selection';
import { d3keybinding as d3_keybinding } from '../lib/d3.keybinding.js';
import { svgNotes } from '../svg';
import {
modeAddArea,
modeAddLine,
modeAddPoint,
modeAddNote,
modeBrowse
} from '../modes';
@@ -19,7 +22,8 @@ export function uiModes(context) {
var modes = [
modeAddPoint(context),
modeAddLine(context),
modeAddArea(context)
modeAddArea(context),
modeAddNote(context)
];
@@ -29,6 +33,13 @@ export function uiModes(context) {
}
function toggleNewNote() {
return svgNotes().enabled()
&& context.connection().authenticated()
&& ~~context.map().zoom() >= 12;
}
return function(selection) {
var buttons = selection.selectAll('button.add-button')
.data(modes);
@@ -36,7 +47,10 @@ export function uiModes(context) {
buttons = buttons.enter()
.append('button')
.attr('tabindex', -1)
.attr('class', function(mode) { return mode.id + ' add-button col4'; })
.attr('class', function(mode) { return mode.id + ' add-button col3'; })
// .classed('disabled', function(mode) {
// return mode.id === 'add-note' && !svgNotes.enabled; // disable notes button
// })
.on('click.mode-buttons', function(mode) {
// When drawing, ignore accidental clicks on mode buttons - #4042
var currMode = context.mode().id;
@@ -109,10 +123,13 @@ export function uiModes(context) {
.on('enter.modes', update);
function update() {
selection.selectAll('button.add-button')
.filter(function(d) { return d.id !== 'add-note'; }) // disable all but add-note
.property('disabled', !editable());
selection.selectAll('button.add-note') // disable add-note
.property('disabled', !toggleNewNote());
}
};
}