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 froca from "../services/froca.js";
import branchService from "../services/branches.js";
import appContext from "../services/app_context.js";
const $dialog = $("#clone-to-dialog");
const $form = $("#clone-to-form");
@ -14,6 +15,10 @@ const $noteList = $("#clone-to-note-list");
let clonedNoteIds;
export async function showDialog(noteIds) {
if (!noteIds || noteIds.length === 0) {
noteIds = [ appContext.tabManager.getActiveContextNoteId() ]
}
clonedNoteIds = [];
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 ShowNoteSourceButton from "../widgets/buttons/show_note_source.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 {
constructor(customWidgets) {
@ -112,6 +113,7 @@ export default class DesktopLayout {
.section(new PromotedAttributesWidget())
.section(new OwnedAttributeListWidget())
.section(new InheritedAttributesWidget())
.section(new NotePathsWidget())
.section(new LinkMapWidget())
.section(new NoteInfoWidget())
.button(new ButtonWidget()

View File

@ -4,7 +4,7 @@ export default class CreatePaneButton extends ButtonWidget {
constructor() {
super();
this.icon("bx-window-open bx-rotate-90")
this.icon("bx-dock-right")
.title("Create new pane")
.titlePlacement("bottom")
.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) {
let $sectionToActivate, $lastActiveSection;
this.$titleContainer.empty().append('<div class="section-title section-title-empty">');
this.$titleContainer.empty();
for (const sectionWidget of this.sectionWidgets) {
const ret = sectionWidget.getTitle(note);

View File

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