mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +01:00
added new label "sorted" which will keep children notes alphabetically sorted, fixes #82
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user