From 3dbd80d5a60f19228b74a7a4b65e423f6c26206d Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 13 Feb 2021 22:47:06 +0100 Subject: [PATCH] relocated note paths widget into note title row --- .../layouts/desktop_extra_window_layout.js | 2 + .../app/layouts/desktop_main_window_layout.js | 2 +- src/public/app/widgets/note_paths.js | 88 ++----------------- 3 files changed, 11 insertions(+), 81 deletions(-) diff --git a/src/public/app/layouts/desktop_extra_window_layout.js b/src/public/app/layouts/desktop_extra_window_layout.js index a9adc7105..aef4df0da 100644 --- a/src/public/app/layouts/desktop_extra_window_layout.js +++ b/src/public/app/layouts/desktop_extra_window_layout.js @@ -21,6 +21,7 @@ import FilePropertiesWidget from "../widgets/type_property_widgets/file_properti import ImagePropertiesWidget from "../widgets/type_property_widgets/image_properties.js"; import NotePropertiesWidget from "../widgets/type_property_widgets/note_properties.js"; import NoteIconWidget from "../widgets/note_icon.js"; +import NotePathsWidget from "../widgets/note_paths.js"; export default class DesktopExtraWindowLayout { constructor(customWidgets) { @@ -48,6 +49,7 @@ export default class DesktopExtraWindowLayout { .overflowing() .child(new NoteIconWidget()) .child(new NoteTitleWidget()) + .child(new NotePathsWidget().hideInZenMode()) .child(new NoteTypeWidget().hideInZenMode()) .child(new NoteActionsWidget().hideInZenMode()) ) diff --git a/src/public/app/layouts/desktop_main_window_layout.js b/src/public/app/layouts/desktop_main_window_layout.js index 80949eec4..663a7bfe9 100644 --- a/src/public/app/layouts/desktop_main_window_layout.js +++ b/src/public/app/layouts/desktop_main_window_layout.js @@ -149,7 +149,6 @@ export default class DesktopMainWindowLayout { .filling() .child(new SidePaneContainer('left') .hideInZenMode() - .child(new TabCachingWidget(() => new NotePathsWidget())) .child(appContext.mainTreeWidget) .child(...this.customWidgets.get('left-pane')) ) @@ -160,6 +159,7 @@ export default class DesktopMainWindowLayout { .overflowing() .child(new NoteIconWidget()) .child(new NoteTitleWidget()) + .child(new NotePathsWidget().hideInZenMode()) .child(new NoteTypeWidget().hideInZenMode()) .child(new NoteActionsWidget().hideInZenMode()) ) diff --git a/src/public/app/widgets/note_paths.js b/src/public/app/widgets/note_paths.js index 1c5bf5706..a43a1df5f 100644 --- a/src/public/app/widgets/note_paths.js +++ b/src/public/app/widgets/note_paths.js @@ -4,53 +4,25 @@ import linkService from "../services/link.js"; import hoistedNoteService from "../services/hoisted_note.js"; const TPL = ` -
+`; export default class NotePathsWidget extends TabAwareWidget { @@ -58,52 +30,8 @@ export default class NotePathsWidget extends TabAwareWidget { this.$widget = $(TPL); this.overflowing(); - this.$currentPath = this.$widget.find('.current-path'); - this.$dropdown = this.$widget.find(".dropdown"); - this.$dropdownToggle = this.$widget.find('.dropdown-toggle'); - - this.$notePathList = this.$dropdown.find(".note-path-list"); - - this.$dropdown.on('show.bs.dropdown', () => this.renderDropdown()); - } - - async refreshWithNote(note) { - const noteIdsPath = treeService.parseNotePath(this.notePath); - - this.$currentPath.empty(); - - let parentNoteId = 'root'; - let curPath = ''; - - let passedHoistedNote = false; - - for (let i = 0; i < noteIdsPath.length; i++) { - const noteId = noteIdsPath[i]; - - curPath += (curPath ? '/' : '') + noteId; - - if (noteId === hoistedNoteService.getHoistedNoteId()) { - passedHoistedNote = true; - } - - if (passedHoistedNote && (noteId !== hoistedNoteService.getHoistedNoteId() || noteIdsPath.length - i < 3)) { - this.$currentPath.append( - $("") - .attr('href', '#' + curPath) - .attr('data-note-path', curPath) - .addClass('no-tooltip-preview') - .text(await treeService.getNoteTitle(noteId, parentNoteId)) - ); - - if (i !== noteIdsPath.length - 1) { - this.$currentPath.append(' / '); - } - } - - parentNoteId = noteId; - } - - this.$dropdownToggle.dropdown('hide'); + this.$notePathList = this.$widget.find(".note-path-list"); + this.$widget.on('show.bs.dropdown', () => this.renderDropdown()); } async renderDropdown() {