import TabAwareWidget from "./tab_aware_widget.js";
import treeService from "../services/tree.js";
import linkService from "../services/link.js";
const TPL = `
")
.addClass("dropdown-header")
.text('This note is placed into the following paths:')
);
if (this.noteId === 'root') {
await this.addPath('root');
return;
}
for (const notePathRecord of this.note.getSortedNotePaths(this.hoistedNoteId)) {
await this.addPath(notePathRecord);
}
const cloneLink = $("
")
.addClass("dropdown-header")
.append(
$('')
.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) {
const notePath = notePathRecord.notePath.join('/');
const title = await treeService.getNotePathTitle(notePath);
const $noteLink = await linkService.createNoteLink(notePath, {title});
$noteLink
.addClass("dropdown-item");
$noteLink
.find('a')
.addClass("no-tooltip-preview");
const icons = [];
if (this.notePath === notePath) {
$noteLink.addClass("path-current");
}
if (notePathRecord.isInHoistedSubTree) {
$noteLink.addClass("path-in-hoisted-subtree");
}
else {
icons.push(` `);
}
if (notePathRecord.isArchived) {
$noteLink.addClass("path-archived");
icons.push(` `);
}
if (notePathRecord.isSearch) {
$noteLink.addClass("path-search");
icons.push(` `);
}
if (icons.length > 0) {
$noteLink.append(` ${icons.join(' ')}`);
}
this.$notePathList.append($noteLink);
}
entitiesReloadedEvent({loadResults}) {
if (loadResults.getBranches().find(branch => branch.noteId === this.noteId)
|| loadResults.isNoteReloaded(this.noteId)) {
this.refresh();
}
}
async refresh() {
await super.refresh();
this.$widget.find('.dropdown-toggle').dropdown('hide');
}
}