added new label "sorted" which will keep children notes alphabetically sorted, fixes #82

This commit is contained in:
azivner
2018-08-01 09:26:02 +02:00
parent 9452fc236b
commit 2d24bf81dd
12 changed files with 100 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ const optionService = require('./options');
const dateUtils = require('./date_utils');
const syncTableService = require('./sync_table');
const labelService = require('./labels');
const eventService = require('./events');
const repository = require('./repository');
const Note = require('../entities/note');
const NoteImage = require('../entities/note_image');
@@ -34,6 +35,10 @@ async function getNewNotePosition(parentNoteId, noteData) {
return newNotePos;
}
async function triggerNoteTitleChanged(note) {
await eventService.emit(eventService.NOTE_TITLE_CHANGED, note);
}
async function createNewNote(parentNoteId, noteData) {
const newNotePos = await getNewNotePosition(parentNoteId, noteData);
@@ -60,6 +65,8 @@ async function createNewNote(parentNoteId, noteData) {
isExpanded: 0
}).save();
await triggerNoteTitleChanged(note);
return {
note,
branch
@@ -92,6 +99,8 @@ async function createNote(parentNoteId, title, content = "", extraOptions = {})
}
}
await triggerNoteTitleChanged(note);
return {note, branch};
}
@@ -200,11 +209,17 @@ async function updateNote(noteId, noteUpdates) {
await saveNoteRevision(note);
const noteTitleChanged = note.title !== noteUpdates.title;
note.title = noteUpdates.title;
note.setContent(noteUpdates.content);
note.isProtected = noteUpdates.isProtected;
await note.save();
if (noteTitleChanged) {
await triggerNoteTitleChanged(note);
}
await saveNoteImages(note);
await protectNoteRevisions(note);