merged tree utils into tree service

This commit is contained in:
zadam 2020-01-25 09:56:08 +01:00
parent 7a62d1636b
commit 3254b551d8
22 changed files with 168 additions and 188 deletions

View file

@ -12,7 +12,6 @@ import ScriptContext from './services/script_context.js';
import sync from './services/sync.js';
import treeService from './services/tree.js';
import treeChanges from './services/branches.js';
import treeUtils from './services/tree_utils.js';
import utils from './services/utils.js';
import server from './services/server.js';
import Entrypoints from './services/entrypoints.js';

View file

@ -1,6 +1,6 @@
import linkService from '../services/link.js';
import noteDetailService from '../services/note_detail.js';
import treeUtils from '../services/tree_utils.js';
import treeService from '../services/tree.js';
import noteAutocompleteService from "../services/note_autocomplete.js";
import utils from "../services/utils.js";
@ -23,7 +23,7 @@ export async function showDialog() {
$linkTitle.val('');
async function setDefaultLinkTitle(noteId) {
const noteTitle = await treeUtils.getNoteTitle(noteId);
const noteTitle = await treeService.getNoteTitle(noteId);
$linkTitle.val(noteTitle);
}
@ -35,7 +35,7 @@ export async function showDialog() {
return false;
}
const noteId = treeUtils.getNoteIdFromNotePath(suggestion.path);
const noteId = treeService.getNoteIdFromNotePath(suggestion.path);
if (noteId) {
setDefaultLinkTitle(noteId);
@ -43,7 +43,7 @@ export async function showDialog() {
});
$autoComplete.on('autocomplete:cursorchanged', function(event, suggestion, dataset) {
const noteId = treeUtils.getNoteIdFromNotePath(suggestion.path);
const noteId = treeService.getNoteIdFromNotePath(suggestion.path);
setDefaultLinkTitle(noteId);
});

View file

@ -1,7 +1,7 @@
import noteDetailService from '../services/note_detail.js';
import server from '../services/server.js';
import toastService from "../services/toast.js";
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import attributeAutocompleteService from "../services/attribute_autocomplete.js";
import utils from "../services/utils.js";
import linkService from "../services/link.js";
@ -66,7 +66,7 @@ function AttributesModel() {
for (const attr of ownedAttributes) {
attr.labelValue = attr.type === 'label' ? attr.value : '';
attr.relationValue = attr.type === 'relation' ? (await treeUtils.getNoteTitle(attr.value)) : '';
attr.relationValue = attr.type === 'relation' ? (await treeService.getNoteTitle(attr.value)) : '';
attr.selectedPath = attr.type === 'relation' ? attr.value : '';
attr.labelDefinition = (attr.type === 'label-definition' && attr.value) ? attr.value : {
labelType: "text",
@ -151,7 +151,7 @@ function AttributesModel() {
attr.value = attr.labelValue;
}
else if (attr.type === 'relation') {
attr.value = treeUtils.getNoteIdFromNotePath(attr.selectedPath);
attr.value = treeService.getNoteIdFromNotePath(attr.selectedPath);
}
else if (attr.type === 'label-definition') {
attr.value = attr.labelDefinition;

View file

@ -1,7 +1,7 @@
import treeService from '../services/tree.js';
import server from '../services/server.js';
import treeCache from "../services/tree_cache.js";
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import toastService from "../services/toast.js";
import utils from "../services/utils.js";
@ -34,7 +34,7 @@ export async function showDialog(node) {
$treePrefixInput.val(branch.prefix);
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
const noteTitle = await treeService.getNoteTitle(node.data.noteId);
$noteTitle.text(" - " + noteTitle);
}

View file

@ -1,7 +1,7 @@
import noteAutocompleteService from "../services/note_autocomplete.js";
import utils from "../services/utils.js";
import cloningService from "../services/cloning.js";
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import toastService from "../services/toast.js";
import treeCache from "../services/tree_cache.js";
@ -43,7 +43,7 @@ export async function showDialog(noteIds) {
}
async function cloneNotesTo(notePath) {
const targetNoteId = treeUtils.getNoteIdFromNotePath(notePath);
const targetNoteId = treeService.getNoteIdFromNotePath(notePath);
for (const cloneNoteId of clonedNoteIds) {
await cloningService.cloneNoteTo(cloneNoteId, targetNoteId, $clonePrefix.val());

View file

@ -1,4 +1,4 @@
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import utils from "../services/utils.js";
import ws from "../services/ws.js";
import toastService from "../services/toast.js";
@ -43,11 +43,11 @@ export async function showDialog(notePath, defaultType) {
$dialog.modal();
const {noteId, parentNoteId} = treeUtils.getNoteIdAndParentIdFromNotePath(notePath);
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
branchId = await treeCache.getBranchId(parentNoteId, noteId);
const noteTitle = await treeUtils.getNoteTitle(noteId);
const noteTitle = await treeService.getNoteTitle(noteId);
$noteTitle.html(noteTitle);
}

View file

@ -1,5 +1,5 @@
import utils from '../services/utils.js';
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import importService from "../services/import.js";
const $dialog = $("#import-dialog");
@ -30,7 +30,7 @@ export async function showDialog(noteId) {
parentNoteId = noteId;
$noteTitle.text(await treeUtils.getNoteTitle(parentNoteId));
$noteTitle.text(await treeService.getNoteTitle(parentNoteId));
$dialog.modal();
}

View file

@ -1,4 +1,4 @@
import treeUtils from '../services/tree_utils.js';
import treeService from '../services/tree.js';
import noteAutocompleteService from '../services/note_autocomplete.js';
import utils from "../services/utils.js";
@ -29,7 +29,7 @@ $form.on('submit', () => {
$dialog.modal('hide');
if (callback) {
callback(treeUtils.getNoteIdFromNotePath(notePath));
callback(treeService.getNoteIdFromNotePath(notePath));
}
}
else {

View file

@ -1,7 +1,7 @@
import noteAutocompleteService from "../services/note_autocomplete.js";
import utils from "../services/utils.js";
import cloningService from "../services/cloning.js";
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import toastService from "../services/toast.js";
import treeCache from "../services/tree_cache.js";
import treeChangesService from "../services/branches.js";

View file

@ -5,7 +5,7 @@ import treeBuilder from "./services/tree_builder.js";
import contextMenuWidget from "./services/context_menu.js";
import treeChangesService from "./services/branches.js";
import utils from "./services/utils.js";
import treeUtils from "./services/tree_utils.js";
import treeService from "./services/tree.js";
import appContext from "./services/app_context.js";
window.glob.isDesktop = utils.isDesktop;
@ -60,7 +60,7 @@ async function showTree() {
showDetailPane();
const notePath = await treeUtils.getNotePath(node);
const notePath = await treeService.getNotePath(node);
},
expand: (event, data) => treeService.setExpandedToServer(data.node.data.branchId, true),
@ -109,7 +109,7 @@ $detail.on("click", ".note-menu-button", async e => {
selectContextMenuItem: async (event, cmd) => {
if (cmd === "insertNoteAfter") {
const parentNoteId = node.data.parentNoteId;
const isProtected = await treeUtils.getParentProtectedStatus(node);
const isProtected = await treeService.getParentProtectedStatus(node);
treeService.createNote(node, parentNoteId, 'after', { isProtected: isProtected });
}

View file

@ -2,8 +2,6 @@ import GlobalButtonsWidget from "../widgets/global_buttons.js";
import SearchBoxWidget from "../widgets/search_box.js";
import SearchResultsWidget from "../widgets/search_results.js";
import NoteTreeWidget from "../widgets/note_tree.js";
import treeService from "./tree.js";
import noteDetailService from "./note_detail.js";
import TabContext from "./tab_context.js";
import server from "./server.js";
import TabRowWidget from "../widgets/tab_row.js";
@ -22,7 +20,7 @@ import GlobalMenuWidget from "../widgets/global_menu.js";
import RowFlexContainer from "../widgets/row_flex_container.js";
import StandardTopWidget from "../widgets/standard_top_widget.js";
import treeCache from "./tree_cache.js";
import treeUtils from "./tree_utils.js";
import treeService from "./tree.js";
import NotePathsWidget from "../widgets/note_paths.js";
import RunScriptButtonsWidget from "../widgets/run_script_buttons.js";
import ProtectedNoteSwitchWidget from "../widgets/protected_note_switch.js";
@ -163,7 +161,7 @@ class AppContext {
const activeTabContext = this.getActiveTabContext();
if (activeTabContext && activeTabContext.notePath) {
const note = await treeCache.getNote(treeUtils.getNoteIdFromNotePath(activeTabContext.notePath));
const note = await treeCache.getNote(treeService.getNoteIdFromNotePath(activeTabContext.notePath));
// it helps navigating in history if note title is included in the title
document.title += " - " + note.title;

View file

@ -1,6 +1,6 @@
import server from "./server.js";
import ws from "./ws.js";
import treeUtils from "./tree_utils.js";
import treeService from "./tree.js";
import noteAutocompleteService from "./note_autocomplete.js";
import Component from "../widgets/component.js";
import utils from "./utils.js";

View file

@ -3,7 +3,6 @@ import utils from './utils.js';
import server from './server.js';
import toastService from "./toast.js";
import treeCache from "./tree_cache.js";
import treeUtils from "./tree_utils.js";
import hoistedNoteService from "./hoisted_note.js";
import noteDetailService from "./note_detail.js";
import ws from "./ws.js";
@ -83,7 +82,7 @@ async function getNextNode(nodes) {
next = nodes[0].getParent();
}
return treeUtils.getNotePath(next);
return treeService.getNotePath(next);
}
async function deleteNodes(branchIdsToDelete) {

View file

@ -1,7 +1,5 @@
import treeService from './tree.js';
import treeUtils from './tree_utils.js';
import contextMenuService from "./context_menu.js";
import noteDetailService from "./note_detail.js";
import appContext from "./app_context.js";
function getNotePathFromUrl(url) {
@ -22,9 +20,9 @@ async function createNoteLink(notePath, options = {}) {
const showNotePath = options.showNotePath === undefined ? false : options.showNotePath;
if (!noteTitle) {
const {noteId, parentNoteId} = treeUtils.getNoteIdAndParentIdFromNotePath(notePath);
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
noteTitle = await treeUtils.getNoteTitle(noteId, parentNoteId);
noteTitle = await treeService.getNoteTitle(noteId, parentNoteId);
}
const $noteLink = $("<a>", {
@ -49,7 +47,7 @@ async function createNoteLink(notePath, options = {}) {
const parentNotePath = noteIds.join("/").trim();
if (parentNotePath) {
$container.append($("<small>").text(" (" + await treeUtils.getNotePathTitle(parentNotePath) + ")"));
$container.append($("<small>").text(" (" + await treeService.getNotePathTitle(parentNotePath) + ")"));
}
}
}

View file

@ -1,5 +1,5 @@
import noteDetailService from "./note_detail.js";
import treeUtils from "./tree_utils.js";
import treeService from "./tree.js";
import linkService from "./link.js";
import server from "./server.js";
@ -40,7 +40,7 @@ async function mouseEnterHandler() {
return;
}
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
const noteId = treeService.getNoteIdFromNotePath(notePath);
const notePromise = noteDetailService.loadNote(noteId);
const attributePromise = server.get(`notes/${noteId}/attributes`);

View file

@ -5,10 +5,9 @@ import Attributes from "./attributes.js";
import utils from "./utils.js";
import optionsService from "./options.js";
import appContext from "./app_context.js";
import treeUtils from "./tree_utils.js";
import treeService from "./tree.js";
import noteDetailService from "./note_detail.js";
import Component from "../widgets/component.js";
import treeService from "./tree.js";
let showSidebarInNewTab = true;
@ -52,7 +51,7 @@ class TabContext extends Component {
await this.trigger('beforeNoteSwitch', {tabId: this.tabId}, true);
this.notePath = notePath;
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
const noteId = treeService.getNoteIdFromNotePath(notePath);
/** @property {NoteFull} */
this.note = await noteDetailService.loadNote(noteId);

View file

@ -1,7 +1,6 @@
import ws from './ws.js';
import noteDetailService from './note_detail.js';
import protectedSessionHolder from './protected_session_holder.js';
import treeUtils from './tree_utils.js';
import utils from './utils.js';
import server from './server.js';
import treeCache from './tree_cache.js';
@ -28,7 +27,7 @@ async function setPrefix(branchId, prefix) {
}
async function setNodeTitleWithPrefix(node) {
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
const noteTitle = await getNoteTitle(node.data.noteId);
const branch = treeCache.getBranch(node.data.branchId);
const prefix = branch.prefix;
@ -214,14 +213,14 @@ async function treeInitialized() {
// (useful, among others, for opening clipped notes from clipper)
if (location.hash) {
const notePath = location.hash.substr(1);
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
const noteId = getNoteIdFromNotePath(notePath);
if (noteId && await treeCache.noteExists(noteId)) {
for (const tab of openTabs) {
tab.active = false;
}
const foundTab = openTabs.find(tab => noteId === treeUtils.getNoteIdFromNotePath(tab.notePath));
const foundTab = openTabs.find(tab => noteId === getNoteIdFromNotePath(tab.notePath));
if (foundTab) {
foundTab.active = true;
@ -238,7 +237,7 @@ async function treeInitialized() {
let filteredTabs = [];
for (const openTab of openTabs) {
const noteId = treeUtils.getNoteIdFromNotePath(openTab.notePath);
const noteId = getNoteIdFromNotePath(openTab.notePath);
if (await treeCache.noteExists(noteId)) {
// note doesn't exist so don't try to open tab for it
@ -500,6 +499,119 @@ async function duplicateNote(noteId, parentNoteId) {
toastService.showMessage(`Note "${origNote.title}" has been duplicated`);
}
async function getParentProtectedStatus(node) {
return await hoistedNoteService.isRootNode(node) ? 0 : node.getParent().data.isProtected;
}
function getNoteIdFromNotePath(notePath) {
if (!notePath) {
return null;
}
const path = notePath.split("/");
const lastSegment = path[path.length - 1];
// path could have also tabId suffix
return lastSegment.split("-")[0];
}
function getNoteIdAndParentIdFromNotePath(notePath) {
let parentNoteId = 'root';
let noteId = '';
if (notePath) {
const path = notePath.split("/");
const lastSegment = path[path.length - 1];
// path could have also tabId suffix
noteId = lastSegment.split("-")[0];
if (path.length > 1) {
parentNoteId = path[path.length - 2];
}
}
return {
parentNoteId,
noteId
}
}
async function getNotePath(node) {
if (!node) {
console.error("Node is null");
return "";
}
const path = [];
while (node && !await hoistedNoteService.isRootNode(node)) {
if (node.data.noteId) {
path.push(node.data.noteId);
}
node = node.getParent();
}
if (node) { // null node can happen directly after unhoisting when tree is still hoisted but option has been changed already
path.push(node.data.noteId); // root or hoisted noteId
}
return path.reverse().join("/");
}
async function getNoteTitle(noteId, parentNoteId = null) {
utils.assertArguments(noteId);
const note = await treeCache.getNote(noteId);
if (!note) {
return "[not found]";
}
let {title} = note;
if (parentNoteId !== null) {
const branchId = note.parentToBranch[parentNoteId];
if (branchId) {
const branch = treeCache.getBranch(branchId);
if (branch && branch.prefix) {
title = branch.prefix + ' - ' + title;
}
}
}
return title;
}
async function getNotePathTitle(notePath) {
utils.assertArguments(notePath);
const titlePath = [];
if (notePath.startsWith('root/')) {
notePath = notePath.substr(5);
}
// special case when we want just root's title
if (notePath === 'root') {
return await getNoteTitle(notePath);
}
let parentNoteId = 'root';
for (const noteId of notePath.split('/')) {
titlePath.push(await getNoteTitle(noteId, parentNoteId));
parentNoteId = noteId;
}
return titlePath.join(' / ');
}
frontendLoaded.then(bundle.executeStartupBundles);
export default {
@ -515,5 +627,11 @@ export default {
createNewTopLevelNote,
duplicateNote,
getRunPath,
setNodeTitleWithPrefix
setNodeTitleWithPrefix,
getParentProtectedStatus,
getNotePath,
getNoteIdFromNotePath,
getNoteIdAndParentIdFromNotePath,
getNoteTitle,
getNotePathTitle
};

View file

@ -2,14 +2,11 @@ import treeService from './tree.js';
import ws from './ws.js';
import protectedSessionService from './protected_session.js';
import treeChangesService from './branches.js';
import treeUtils from './tree_utils.js';
import treeCache from "./tree_cache.js";
import syncService from "./sync.js";
import hoistedNoteService from './hoisted_note.js';
import noteDetailService from './note_detail.js';
import clipboard from './clipboard.js';
import protectedSessionHolder from "./protected_session_holder.js";
import searchNotesService from "./search_notes.js";
import appContext from "./app_context.js";
class TreeContextMenu {
@ -101,7 +98,7 @@ class TreeContextMenu {
async selectContextMenuItem(event, cmd) {
const noteId = this.node.data.noteId;
const notePath = await treeUtils.getNotePath(this.node);
const notePath = await treeService.getNotePath(this.node);
if (cmd === 'openInTab') {
const tabContext = appContext.openEmptyTab();
@ -110,7 +107,7 @@ class TreeContextMenu {
}
else if (cmd.startsWith("insertNoteAfter")) {
const parentNoteId = this.node.data.parentNoteId;
const isProtected = await treeUtils.getParentProtectedStatus(this.node);
const isProtected = await treeService.getParentProtectedStatus(this.node);
const type = cmd.split("_")[1];
treeService.createNote(this.node, parentNoteId, 'after', {

View file

@ -1,125 +0,0 @@
import utils from './utils.js';
import hoistedNoteService from './hoisted_note.js';
import treeCache from "./tree_cache.js";
async function getParentProtectedStatus(node) {
return await hoistedNoteService.isRootNode(node) ? 0 : node.getParent().data.isProtected;
}
function getNoteIdFromNotePath(notePath) {
if (!notePath) {
return null;
}
const path = notePath.split("/");
const lastSegment = path[path.length - 1];
// path could have also tabId suffix
return lastSegment.split("-")[0];
}
function getNoteIdAndParentIdFromNotePath(notePath) {
let parentNoteId = 'root';
let noteId = '';
if (notePath) {
const path = notePath.split("/");
const lastSegment = path[path.length - 1];
// path could have also tabId suffix
noteId = lastSegment.split("-")[0];
if (path.length > 1) {
parentNoteId = path[path.length - 2];
}
}
return {
parentNoteId,
noteId
}
}
async function getNotePath(node) {
if (!node) {
console.error("Node is null");
return "";
}
const path = [];
while (node && !await hoistedNoteService.isRootNode(node)) {
if (node.data.noteId) {
path.push(node.data.noteId);
}
node = node.getParent();
}
if (node) { // null node can happen directly after unhoisting when tree is still hoisted but option has been changed already
path.push(node.data.noteId); // root or hoisted noteId
}
return path.reverse().join("/");
}
async function getNoteTitle(noteId, parentNoteId = null) {
utils.assertArguments(noteId);
const note = await treeCache.getNote(noteId);
if (!note) {
return "[not found]";
}
let {title} = note;
if (parentNoteId !== null) {
const branchId = note.parentToBranch[parentNoteId];
if (branchId) {
const branch = treeCache.getBranch(branchId);
if (branch && branch.prefix) {
title = branch.prefix + ' - ' + title;
}
}
}
return title;
}
async function getNotePathTitle(notePath) {
utils.assertArguments(notePath);
const titlePath = [];
if (notePath.startsWith('root/')) {
notePath = notePath.substr(5);
}
// special case when we want just root's title
if (notePath === 'root') {
return await getNoteTitle(notePath);
}
let parentNoteId = 'root';
for (const noteId of notePath.split('/')) {
titlePath.push(await getNoteTitle(noteId, parentNoteId));
parentNoteId = noteId;
}
return titlePath.join(' / ');
}
export default {
getParentProtectedStatus,
getNotePath,
getNoteIdFromNotePath,
getNoteIdAndParentIdFromNotePath,
getNoteTitle,
getNotePathTitle,
};

View file

@ -1,6 +1,5 @@
import TabAwareWidget from "./tab_aware_widget.js";
import treeService from "../services/tree.js";
import treeUtils from "../services/tree_utils.js";
import linkService from "../services/link.js";
const TPL = `
@ -71,7 +70,7 @@ export default class NotePathsWidget extends TabAwareWidget {
}
async addPath(notePath, isCurrent) {
const title = await treeUtils.getNotePathTitle(notePath);
const title = await treeService.getNotePathTitle(notePath);
const noteLink = await linkService.createNoteLink(notePath, {title});

View file

@ -1,8 +1,6 @@
import hoistedNoteService from "../services/hoisted_note.js";
import searchNotesService from "../services/search_notes.js";
import treeService from "../services/tree.js";
import treeUtils from "../services/tree_utils.js";
import noteDetailService from "../services/note_detail.js";
import utils from "../services/utils.js";
import contextMenuWidget from "../services/context_menu.js";
import treeKeyBindingService from "../services/tree_keybindings.js";
@ -51,7 +49,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
if (e.which === 2) {
const node = $.ui.fancytree.getNode(e);
treeUtils.getNotePath(node).then(notePath => {
treeService.getNotePath(node).then(notePath => {
if (notePath) {
const tabContext = appContext.openEmptyTab();
tabContext.setNote(notePath);
@ -89,7 +87,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
else if (event.ctrlKey) {
const tabContext = appContext.openEmptyTab();
treeUtils.getNotePath(node).then(notePath => tabContext.setNote(notePath));
treeService.getNotePath(node).then(notePath => tabContext.setNote(notePath));
appContext.activateTab(tabContext.tabId);
}
else {
@ -105,7 +103,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
// click event won't propagate so let's close context menu manually
contextMenuWidget.hideContextMenu();
const notePath = await treeUtils.getNotePath(data.node);
const notePath = await treeService.getNotePath(data.node);
const activeTabContext = this.appContext.getActiveTabContext();
await activeTabContext.setNote(notePath);
@ -463,7 +461,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
async createNoteAfterListener() {
const node = this.getActiveNode();
const parentNoteId = node.data.parentNoteId;
const isProtected = await treeUtils.getParentProtectedStatus(node);
const isProtected = await treeService.getParentProtectedStatus(node);
if (node.data.noteId === 'root' || node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {
return;
@ -524,7 +522,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
const activeNode = this.getActiveNode();
const activeNotePath = activeNode !== null ? await treeUtils.getNotePath(activeNode) : null;
const activeNotePath = activeNode !== null ? await treeService.getNotePath(activeNode) : null;
await this.reload(notes);

View file

@ -1,6 +1,6 @@
import server from "../services/server.js";
import ws from "../services/ws.js";
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
import noteAutocompleteService from "../services/note_autocomplete.js";
import TabAwareWidget from "./tab_aware_widget.js";
@ -185,7 +185,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
}
else if (valueAttr.type === 'relation') {
if (valueAttr.value) {
$input.val(await treeUtils.getNoteTitle(valueAttr.value));
$input.val(await treeService.getNoteTitle(valueAttr.value));
}
// no need to wait for this
@ -247,7 +247,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
else if ($attr.prop("attribute-type") === "relation") {
const selectedPath = $attr.getSelectedPath();
value = selectedPath ? treeUtils.getNoteIdFromNotePath(selectedPath) : "";
value = selectedPath ? treeService.getNoteIdFromNotePath(selectedPath) : "";
}
else {
value = $attr.val();