diff --git a/css/65_data.css b/css/65_data.css index fa1a18ba3..078d8914a 100644 --- a/css/65_data.css +++ b/css/65_data.css @@ -71,4 +71,6 @@ #new-comment-input { width: 100%; height: 100px; + max-height: 300px; + min-height: 100px; } diff --git a/modules/behavior/select.js b/modules/behavior/select.js index 9aed955e9..9e0b3fee9 100644 --- a/modules/behavior/select.js +++ b/modules/behavior/select.js @@ -163,6 +163,7 @@ export function behaviorSelect(context) { .enter(modeSelectNote(context, datum.id)); } else { // clicked nothing.. + context.selectedNoteID(null); if (!isMultiselect && mode.id !== 'browse') { context.enter(modeBrowse(context)); diff --git a/modules/modes/select_note.js b/modules/modes/select_note.js index 10d1e50ac..ed2a1ed94 100644 --- a/modules/modes/select_note.js +++ b/modules/modes/select_note.js @@ -101,7 +101,7 @@ export function modeSelectNote(context, selectedNoteID) { context.surface() .selectAll('.note.selected') - .classed('selected', false); + .classed('selected hovered', false); context.map() .on('drawn.select', null); diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 10adf2c3d..1118488b7 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -350,7 +350,7 @@ export function rendererMap(context) { surface.selectAll('.layer-osm *').remove(); var mode = context.mode(); - if (mode && mode.id !== 'save') { + if (mode && mode.id !== 'save' && mode.id !== 'select_note') { context.enter(modeBrowse(context)); } diff --git a/modules/svg/notes.js b/modules/svg/notes.js index 7a2d174b4..344e75e64 100644 --- a/modules/svg/notes.js +++ b/modules/svg/notes.js @@ -65,34 +65,11 @@ export function svgNotes(projection, context, dispatch) { function click(which) { - // _selected = which; - context.map().centerEase(which.loc); - - // layer.selectAll('.note') - // .classed('selected', function(d) { return d === _selected; }); - - // context.ui().sidebar.show(noteEditor.note(which)); + if (context.selectedNoteID() === which.id) { + context.map().centerEase(which.loc); + } } - - // function mouseover(which) { - // layer.selectAll('.note') - // .classed('hovered', function(d) { return d === which; }); - - // // context.ui().sidebar.show(noteEditor.note(which)); - // } - - - // function mouseout() { - // layer.selectAll('.note') - // .classed('hovered', false); - - // // TODO: check if the item was clicked. If so, it should remain on the sidebar. - // // TODO: handle multi-clicks. Otherwise, utilize behavior/select.js - // // context.ui().sidebar.hide(); - // } - - function update() { var service = getService(); var selectedID = context.selectedNoteID(); diff --git a/modules/ui/note_editor.js b/modules/ui/note_editor.js index 097efbd9c..636999115 100644 --- a/modules/ui/note_editor.js +++ b/modules/ui/note_editor.js @@ -18,9 +18,10 @@ var _newComment; export function uiNoteEditor(context) { - var dispatch = d3_dispatch('change', 'cancel', 'save'); + var dispatch = d3_dispatch('change', 'cancel', 'save', 'changeInput'); var formFields = uiFormFields(context); var _fieldsArr; + var _modified = false; var _note; function localeDateString(s) { @@ -95,6 +96,24 @@ export function uiNoteEditor(context) { } + function newComment(selection) { + if (!context.selectedNoteID()) return; + // New Comment + var saveSection = selection.selectAll('.save-section') + .data([0]); + + saveSection = saveSection.enter() + .append('div') + .attr('class','save-section cf') + .merge(saveSection); + + saveSection + .call(saveHeader) + .call(input) + .call(buttons); + } + + function saveHeader(selection) { var header = selection.selectAll('.notesSaveHeader') .data([0]); @@ -118,7 +137,7 @@ export function uiNoteEditor(context) { .attr('placeholder', t('note.inputPlaceholder')) .attr('maxlength', 1000) .call(utilNoAuto) - // .on('input', change(true)) + .on('input', change(true)) .on('blur', change()) .on('change', change()) .merge(input); @@ -126,9 +145,7 @@ export function uiNoteEditor(context) { function change(onInput) { return function() { - var t = {}; - // t[field.key] = utilGetSetValue(input) || undefined; - dispatch.call('change', this, t, onInput); + dispatch.call('changeInput', this, onInput); }; } } @@ -201,22 +218,6 @@ export function uiNoteEditor(context) { }); } - function newComment(selection) { - // New Comment - var saveSection = selection.selectAll('.save-section') - .data([0]); - - saveSection = saveSection.enter() - .append('div') - .attr('class','save-section cf') - .merge(saveSection); - - saveSection - .call(saveHeader) - .call(input) - .call(buttons); - } - function render(selection) { var header = selection.selectAll('.header') @@ -245,6 +246,7 @@ export function uiNoteEditor(context) { .call(noteHeader) .call(noteComments) .call(newComment); + }