From 189202b1f644fd1c7490a2c0d4b0c2e957e9df01 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 29 Mar 2020 19:43:04 +0200 Subject: [PATCH] added context menu "recent changes in subtree" --- src/public/javascripts/dialogs/recent_changes.js | 8 ++++++-- src/public/javascripts/services/tree_context_menu.js | 3 ++- src/public/javascripts/widgets/note_tree.js | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/public/javascripts/dialogs/recent_changes.js b/src/public/javascripts/dialogs/recent_changes.js index 42fdd75bb..df07f46d8 100644 --- a/src/public/javascripts/dialogs/recent_changes.js +++ b/src/public/javascripts/dialogs/recent_changes.js @@ -9,10 +9,14 @@ import hoistedNoteService from "../services/hoisted_note.js"; const $dialog = $("#recent-changes-dialog"); const $content = $("#recent-changes-content"); -export async function showDialog() { +export async function showDialog(ancestorNoteId) { utils.openDialog($dialog); - const result = await server.get('recent-changes/' + hoistedNoteService.getHoistedNoteId()); + if (!ancestorNoteId) { + ancestorNoteId = hoistedNoteService.getHoistedNoteId(); + } + + const result = await server.get('recent-changes/' + ancestorNoteId); // preload all notes into cache await treeCache.getNotes(result.map(r => r.noteId), true); diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.js index 6db23878f..cb0d4158e 100644 --- a/src/public/javascripts/services/tree_context_menu.js +++ b/src/public/javascripts/services/tree_context_menu.js @@ -75,7 +75,8 @@ class TreeContextMenu { { title: "Advanced", uiIcon: "empty", enabled: true, items: [ { title: 'Collapse subtree ', command: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes }, { title: "Force note sync", command: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes }, - { title: 'Sort alphabetically ', command: "sortChildNotes", uiIcon: "empty", enabled: noSelectedNotes && notSearch } + { title: 'Sort alphabetically ', command: "sortChildNotes", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, + { title: 'Recent changes in subtree', command: "recentChangesInSubtree", uiIcon: "history", enabled: noSelectedNotes } ] }, { title: "----" }, { title: "Protect subtree", command: "protectSubtree", uiIcon: "check-shield", enabled: noSelectedNotes }, diff --git a/src/public/javascripts/widgets/note_tree.js b/src/public/javascripts/widgets/note_tree.js index 5a4a306cc..5471189ce 100644 --- a/src/public/javascripts/widgets/note_tree.js +++ b/src/public/javascripts/widgets/note_tree.js @@ -737,6 +737,12 @@ export default class NoteTreeWidget extends TabAwareWidget { treeService.sortAlphabetically(node.data.noteId); } + async recentChangesInSubtreeCommand({node}) { + const recentChangesDialog = await import('../dialogs/recent_changes.js'); + + recentChangesDialog.showDialog(node.data.noteId); + } + selectAllNotesInParentCommand({node}) { for (const child of node.getParent().getChildren()) { child.setSelected(true);