support for note path

This commit is contained in:
azivner
2017-11-19 08:47:22 -05:00
parent cc3c9d6428
commit b22eb2db1e
7 changed files with 86 additions and 55 deletions

View File

@@ -21,31 +21,6 @@ const treeUtils = (function() {
return getNodeByKey(key);
}
async function activateNode(noteTreeIdToActivate) {
const noteTreeIdPath = [ noteTreeIdToActivate ];
let note = noteTree.getByNoteId(noteTreeIdToActivate);
while (note) {
if (note.note_pid !== 'root') {
noteTreeIdPath.push(note.note_pid);
}
note = noteTree.getByNoteId(note.note_pid);
}
for (const noteTreeId of noteTreeIdPath.reverse()) {
const node = treeUtils.getNodeByNoteTreeId(noteTreeId);
if (noteTreeId !== noteTreeIdToActivate) {
await node.setExpanded();
}
else {
await node.setActive();
}
}
}
function getNoteTitle(noteId) {
const note = treeUtils.getNodeByKey(noteId);
if (!note) {
@@ -79,13 +54,27 @@ const treeUtils = (function() {
return path.reverse().join(" > ");
}
function getNotePath(node) {
const path = [];
while (node) {
if (node.data.note_tree_id) {
path.push(node.data.note_tree_id);
}
node = node.getParent();
}
return path.reverse().join("/");
}
return {
getParentNoteTreeId,
getParentProtectedStatus,
getNodeByKey,
getNodeByNoteTreeId,
activateNode,
getNoteTitle,
getFullName
getFullName,
getNotePath
};
})();