From 3fee26335550fadc761be4ec07b3235bc625ff95 Mon Sep 17 00:00:00 2001 From: azivner Date: Fri, 16 Nov 2018 22:04:51 +0100 Subject: [PATCH] fixed "paths" styling for BS4 and fix for special case of root note --- src/public/javascripts/services/tree.js | 48 +++++++++++++++++-------- src/public/stylesheets/style.css | 2 +- src/views/setup.ejs | 2 +- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 3294434e4..778c2f01a 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -207,33 +207,51 @@ async function getRunPath(notePath) { return effectivePath.reverse(); } +async function addPath(notePath, isCurrent) { + const title = await treeUtils.getNotePathTitle(notePath); + + const noteLink = await linkService.createNoteLink(notePath, title); + + noteLink + .addClass("no-tooltip-preview") + .addClass("dropdown-item"); + + if (isCurrent) { + noteLink.addClass("current"); + } + + $notePathList.append(noteLink); +} + async function showPaths(noteId, node) { utils.assertArguments(noteId, node); const note = await treeCache.getNote(noteId); - const parents = await note.getParentNotes(); - $notePathCount.html(parents.length + " path" + (parents.length > 0 ? "s" : "")); + if (note.noteId === 'root') { + // root doesn't have any parent, but it's still technically 1 path - $notePathList.empty(); + $notePathCount.html("1 path"); - for (const parentNote of parents) { - const parentNotePath = await getSomeNotePath(parentNote); - // this is to avoid having root notes leading '/' - const notePath = parentNotePath ? (parentNotePath + '/' + noteId) : noteId; - const title = await treeUtils.getNotePathTitle(notePath); + $notePathList.empty(); - const noteLink = await linkService.createNoteLink(notePath, title); + await addPath('root', true); + } + else { + const parents = await note.getParentNotes(); - noteLink.addClass("no-tooltip-preview"); + $notePathCount.html(parents.length + " path" + (parents.length > 1 ? "s" : "")); - const item = $("
  • ").append(noteLink); + $notePathList.empty(); - if (node.getParent().data.noteId === parentNote.noteId) { - item.addClass("current"); + for (const parentNote of parents) { + const parentNotePath = await getSomeNotePath(parentNote); + // this is to avoid having root notes leading '/' + const notePath = parentNotePath ? (parentNotePath + '/' + noteId) : noteId; + const isCurrent = node.getParent().data.noteId === parentNote.noteId; + + await addPath(notePath, isCurrent); } - - $notePathList.append(item); } } diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 6f5b0677d..8e304454b 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -397,7 +397,7 @@ div.ui-tooltip { background-color: #ccc; } -#note-path-list .current a { +#note-path-list a.current { font-weight: bold; } diff --git a/src/views/setup.ejs b/src/views/setup.ejs index 995027dc9..9117b56d3 100644 --- a/src/views/setup.ejs +++ b/src/views/setup.ejs @@ -64,7 +64,7 @@
  • click on Options button in the top right
  • click on Sync tab
  • configure server instance address to the: and click save.
  • -
  • click on "Sync document to the server instance" button
  • +
  • click on "Test sync" button
  • once you've done all this, click here