added note paths section container

This commit is contained in:
zadam 2021-05-29 13:06:09 +02:00
parent 520db931ae
commit 9532a5662f
5 changed files with 39 additions and 43 deletions

View File

@ -4,6 +4,7 @@ import treeService from "../services/tree.js";
import toastService from "../services/toast.js"; import toastService from "../services/toast.js";
import froca from "../services/froca.js"; import froca from "../services/froca.js";
import branchService from "../services/branches.js"; import branchService from "../services/branches.js";
import appContext from "../services/app_context.js";
const $dialog = $("#clone-to-dialog"); const $dialog = $("#clone-to-dialog");
const $form = $("#clone-to-form"); const $form = $("#clone-to-form");
@ -14,6 +15,10 @@ const $noteList = $("#clone-to-note-list");
let clonedNoteIds; let clonedNoteIds;
export async function showDialog(noteIds) { export async function showDialog(noteIds) {
if (!noteIds || noteIds.length === 0) {
noteIds = [ appContext.tabManager.getActiveContextNoteId() ]
}
clonedNoteIds = []; clonedNoteIds = [];
for (const noteId of noteIds) { for (const noteId of noteIds) {

View File

@ -37,6 +37,7 @@ import NoteInfoWidget from "../widgets/type_property_widgets/note_info_widget.js
import BookPropertiesWidget from "../widgets/type_property_widgets/book_properties.js"; import BookPropertiesWidget from "../widgets/type_property_widgets/book_properties.js";
import ShowNoteSourceButton from "../widgets/buttons/show_note_source.js"; import ShowNoteSourceButton from "../widgets/buttons/show_note_source.js";
import LinkMapWidget from "../widgets/type_property_widgets/link_map.js"; import LinkMapWidget from "../widgets/type_property_widgets/link_map.js";
import NotePathsWidget from "../widgets/type_property_widgets/note_paths.js";
export default class DesktopLayout { export default class DesktopLayout {
constructor(customWidgets) { constructor(customWidgets) {
@ -112,6 +113,7 @@ export default class DesktopLayout {
.section(new PromotedAttributesWidget()) .section(new PromotedAttributesWidget())
.section(new OwnedAttributeListWidget()) .section(new OwnedAttributeListWidget())
.section(new InheritedAttributesWidget()) .section(new InheritedAttributesWidget())
.section(new NotePathsWidget())
.section(new LinkMapWidget()) .section(new LinkMapWidget())
.section(new NoteInfoWidget()) .section(new NoteInfoWidget())
.button(new ButtonWidget() .button(new ButtonWidget()

View File

@ -4,7 +4,7 @@ export default class CreatePaneButton extends ButtonWidget {
constructor() { constructor() {
super(); super();
this.icon("bx-window-open bx-rotate-90") this.icon("bx-dock-right")
.title("Create new pane") .title("Create new pane")
.titlePlacement("bottom") .titlePlacement("bottom")
.onClick(widget => widget.triggerCommand("openNewPane", { ntxId: widget.getNtxId() })); .onClick(widget => widget.triggerCommand("openNewPane", { ntxId: widget.getNtxId() }));

View File

@ -164,7 +164,7 @@ export default class CollapsibleSectionContainer extends NoteContextAwareWidget
async refreshWithNote(note, noExplicitActivation = false) { async refreshWithNote(note, noExplicitActivation = false) {
let $sectionToActivate, $lastActiveSection; let $sectionToActivate, $lastActiveSection;
this.$titleContainer.empty().append('<div class="section-title section-title-empty">'); this.$titleContainer.empty();
for (const sectionWidget of this.sectionWidgets) { for (const sectionWidget of this.sectionWidgets) {
const ret = sectionWidget.getTitle(note); const ret = sectionWidget.getTitle(note);

View File

@ -1,21 +1,18 @@
import NoteContextAwareWidget from "./note_context_aware_widget.js"; import NoteContextAwareWidget from "../note_context_aware_widget.js";
import treeService from "../services/tree.js"; import treeService from "../../services/tree.js";
import linkService from "../services/link.js"; import linkService from "../../services/link.js";
const TPL = ` const TPL = `
<div class="dropdown note-paths-widget"> <div class="note-paths-widget">
<style> <style>
.note-path-list-button { .note-paths-widget {
font-size: 120% !important; padding: 12px;
} max-height: 300px;
overflow-y: auto;
.note-path-list-button::after {
display: none !important; // disabling the standard caret
} }
.note-path-list { .note-path-list {
max-height: 700px; margin-top: 10px;
overflow-y: auto;
} }
.note-path-list .path-current { .note-path-list .path-current {
@ -31,12 +28,28 @@ const TPL = `
} }
</style> </style>
<button class="btn dropdown-toggle note-path-list-button bx bx-collection" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Note paths"></button> <div>This note is placed into the following paths:</div>
<ul class="note-path-list dropdown-menu dropdown-menu-right" aria-labelledby="note-path-list-button">
</ul> <ul class="note-path-list"></ul>
<button class="btn btn-sm" data-trigger-command="cloneNoteIdsTo">Clone note to new location...</button>
</div>`; </div>`;
export default class NotePathsWidget extends NoteContextAwareWidget { export default class NotePathsWidget extends NoteContextAwareWidget {
static getType() { return "note-paths"; }
isEnabled() {
return this.note;
}
getTitle() {
return {
show: this.isEnabled(),
title: 'Note Paths',
icon: 'bx bx-collection'
};
}
doRender() { doRender() {
this.$widget = $(TPL); this.$widget = $(TPL);
this.overflowing(); this.overflowing();
@ -45,13 +58,8 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
this.$widget.on('show.bs.dropdown', () => this.renderDropdown()); this.$widget.on('show.bs.dropdown', () => this.renderDropdown());
} }
async renderDropdown() { async refreshWithNote(note) {
this.$notePathList.empty(); this.$notePathList.empty();
this.$notePathList.append(
$("<div>")
.addClass("dropdown-header")
.text('This note is placed into the following paths:')
);
if (this.noteId === 'root') { if (this.noteId === 'root') {
await this.addPath('root'); await this.addPath('root');
@ -61,16 +69,6 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
for (const notePathRecord of this.note.getSortedNotePaths(this.hoistedNoteId)) { for (const notePathRecord of this.note.getSortedNotePaths(this.hoistedNoteId)) {
await this.addPath(notePathRecord); await this.addPath(notePathRecord);
} }
const cloneLink = $("<div>")
.addClass("dropdown-header")
.append(
$('<button class="btn btn-sm">')
.text('Clone note to new location...')
.on('click', () => import("../dialogs/clone_to.js").then(d => d.showDialog([this.noteId])))
);
this.$notePathList.append(cloneLink);
} }
async addPath(notePathRecord) { async addPath(notePathRecord) {
@ -80,9 +78,6 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
const $noteLink = await linkService.createNoteLink(notePath, {title}); const $noteLink = await linkService.createNoteLink(notePath, {title});
$noteLink
.addClass("dropdown-item");
$noteLink $noteLink
.find('a') .find('a')
.addClass("no-tooltip-preview"); .addClass("no-tooltip-preview");
@ -116,7 +111,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
$noteLink.append(` ${icons.join(' ')}`); $noteLink.append(` ${icons.join(' ')}`);
} }
this.$notePathList.append($noteLink); this.$notePathList.append($("<li>").append($noteLink));
} }
entitiesReloadedEvent({loadResults}) { entitiesReloadedEvent({loadResults}) {
@ -126,10 +121,4 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
this.refresh(); this.refresh();
} }
} }
async refresh() {
await super.refresh();
this.$widget.find('.dropdown-toggle').dropdown('hide');
}
} }