import TabAwareWidget from "./tab_aware_widget.js"; import treeService from "../services/tree.js"; import linkService from "../services/link.js"; const TPL = ` `; export default class NotePathsWidget extends TabAwareWidget { doRender() { this.$widget = $(TPL); this.$notePathList = this.$widget.find(".note-path-list"); this.$notePathCount = this.$widget.find(".note-path-count"); return this.$widget; } async refreshWithNote(note, notePath) { if (note.noteId === 'root') { // root doesn't have any parent, but it's still technically 1 path this.$notePathCount.html("1 path"); this.$notePathList.empty(); await this.addPath('root', true); } else { const parents = await note.getParentNotes(); this.$notePathCount.html(parents.length + " path" + (parents.length > 1 ? "s" : "")); this.$notePathList.empty(); const pathSegments = notePath.split("/"); const activeNoteParentNoteId = pathSegments[pathSegments.length - 2]; // we know this is not root so there must be a parent for (const parentNote of parents) { const parentNotePath = await treeService.getSomeNotePath(parentNote); // this is to avoid having root notes leading '/' const notePath = parentNotePath ? (parentNotePath + '/' + note.noteId) : note.noteId; const isCurrent = activeNoteParentNoteId === parentNote.noteId; await this.addPath(notePath, isCurrent); } const cloneLink = $("
") .addClass("dropdown-item") .append( $('