From 2e76de5f34dc0951e84f687af99413afd24203ee Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 18 Nov 2018 23:57:39 +0100 Subject: [PATCH] minor relation map fixes --- .../services/note_detail_relation_map.js | 13 ++++++++----- src/services/notes.js | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/public/javascripts/services/note_detail_relation_map.js b/src/public/javascripts/services/note_detail_relation_map.js index 3c24150e0..2c13b8b89 100644 --- a/src/public/javascripts/services/note_detail_relation_map.js +++ b/src/public/javascripts/services/note_detail_relation_map.js @@ -215,10 +215,17 @@ function initPanZoom() { mapData.notes.push({ noteId: clipboard.noteId, x, y }); + saveData(); + clipboard = null; } return true; + }, + filterKey: function(e, dx, dy, dz) { + // if ALT is pressed then panzoom should bubble the event up + // this is to preserve ALT-LEFT, ALT-RIGHT navigation working + return e.altKey; } }); @@ -315,8 +322,6 @@ function connectionContextMenuHandler(connection, event) { async function connectionCreatedHandler(info, originalEvent) { const connection = info.connection; - const isRelation = relations.some(rel => rel.attributeId === connection.id); - connection.bind("contextmenu", (obj, event) => { if (connection.getType().includes("link")) { // don't create context menu if it's a link since there's nothing to do with link from relation map @@ -365,9 +370,7 @@ async function connectionCreatedHandler(info, originalEvent) { return; } - const attribute = await server.put(`notes/${sourceNoteId}/relations/${name}/to/${targetNoteId}`); - - relations.push({ attributeId: attribute.attributeId , targetNoteId, sourceNoteId, name }); + await server.put(`notes/${sourceNoteId}/relations/${name}/to/${targetNoteId}`); await refresh(); } diff --git a/src/services/notes.js b/src/services/notes.js index 60db6e40e..c7a7f2462 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -68,6 +68,10 @@ async function createNewNote(parentNoteId, noteData) { noteData.type = noteData.type || parentNote.type; noteData.mime = noteData.mime || parentNote.mime; + if (noteData.type === 'text' || noteData.type === 'code') { + noteData.content = noteData.content || ""; + } + const note = await new Note({ noteId: noteData.noteId, // optionally can force specific noteId title: noteData.title,