mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 02:05:53 +01:00
unified/simplified protecting notes & subtree
This commit is contained in:
@@ -83,14 +83,15 @@ async function sortNotes(req) {
|
||||
await treeService.sortNotesAlphabetically(noteId);
|
||||
}
|
||||
|
||||
async function protectSubtree(req) {
|
||||
async function protectNote(req) {
|
||||
const noteId = req.params.noteId;
|
||||
const note = await repository.getNote(noteId);
|
||||
const protect = !!parseInt(req.params.isProtected);
|
||||
const includingSubTree = !!parseInt(req.query.subtree);
|
||||
|
||||
const taskContext = new TaskContext(utils.randomString(10), 'protect-notes', {protect});
|
||||
|
||||
await noteService.protectNoteRecursively(note, protect, taskContext);
|
||||
await noteService.protectNoteRecursively(note, protect, includingSubTree, taskContext);
|
||||
|
||||
taskContext.taskSucceeded();
|
||||
}
|
||||
@@ -183,7 +184,7 @@ module.exports = {
|
||||
undeleteNote,
|
||||
createNote,
|
||||
sortNotes,
|
||||
protectSubtree,
|
||||
protectNote,
|
||||
setNoteTypeMime,
|
||||
getRelationMap,
|
||||
changeTitle,
|
||||
|
||||
@@ -134,7 +134,7 @@ function register(app) {
|
||||
apiRoute(PUT, '/api/notes/:noteId/undelete', notesApiRoute.undeleteNote);
|
||||
apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote);
|
||||
apiRoute(PUT, '/api/notes/:noteId/sort', notesApiRoute.sortNotes);
|
||||
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectSubtree);
|
||||
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote);
|
||||
apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime);
|
||||
apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions);
|
||||
apiRoute(DELETE, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.eraseAllNoteRevisions);
|
||||
|
||||
Reference in New Issue
Block a user