mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
share tree should include branch prefixes, fixes #4096
This commit is contained in:
parent
84c4b368c8
commit
d6a4f1db13
@ -9,21 +9,28 @@ const contentRenderer = require("./content_renderer");
|
|||||||
const assetPath = require("../services/asset_path");
|
const assetPath = require("../services/asset_path");
|
||||||
const appPath = require("../services/app_path");
|
const appPath = require("../services/app_path");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SNote} note
|
||||||
|
* @return {{note: SNote, branch: SBranch}|{}}
|
||||||
|
*/
|
||||||
function getSharedSubTreeRoot(note) {
|
function getSharedSubTreeRoot(note) {
|
||||||
if (note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
|
if (note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
|
||||||
// share root itself is not shared
|
// share root itself is not shared
|
||||||
return null;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// every path leads to share root, but which one to choose?
|
// every path leads to share root, but which one to choose?
|
||||||
// for the sake of simplicity, URLs are not note paths
|
// for the sake of simplicity, URLs are not note paths
|
||||||
const parentNote = note.getParentNotes()[0];
|
const parentBranch = note.getParentBranches()[0];
|
||||||
|
|
||||||
if (parentNote.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
|
if (parentBranch.parentNoteId === shareRoot.SHARE_ROOT_NOTE_ID) {
|
||||||
return note;
|
return {
|
||||||
|
note,
|
||||||
|
branch: parentBranch
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return getSharedSubTreeRoot(parentNote);
|
return getSharedSubTreeRoot(parentBranch.getParentNote());
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNoIndexHeader(note, res) {
|
function addNoIndexHeader(note, res) {
|
||||||
|
@ -52,6 +52,11 @@ class SBranch extends AbstractShacaEntity {
|
|||||||
get parentNote() {
|
get parentNote() {
|
||||||
return this.shaca.notes[this.parentNoteId];
|
return this.shaca.notes[this.parentNoteId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {SNote} */
|
||||||
|
getParentNote() {
|
||||||
|
return this.parentNote;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = SBranch;
|
module.exports = SBranch;
|
||||||
|
@ -68,6 +68,13 @@ class SNote extends AbstractShacaEntity {
|
|||||||
return this.children.map(childNote => this.shaca.getBranchFromChildAndParent(childNote.noteId, this.noteId));
|
return this.children.map(childNote => this.shaca.getBranchFromChildAndParent(childNote.noteId, this.noteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {SBranch[]} */
|
||||||
|
getVisibleChildBranches() {
|
||||||
|
return this.getChildBranches()
|
||||||
|
.filter(branch => !branch.isHidden
|
||||||
|
&& !branch.getNote().isLabelTruthy('shareHiddenFromTree'));
|
||||||
|
}
|
||||||
|
|
||||||
/** @returns {SNote[]} */
|
/** @returns {SNote[]} */
|
||||||
getParentNotes() {
|
getParentNotes() {
|
||||||
return this.parents;
|
return this.parents;
|
||||||
@ -80,10 +87,8 @@ class SNote extends AbstractShacaEntity {
|
|||||||
|
|
||||||
/** @returns {SNote[]} */
|
/** @returns {SNote[]} */
|
||||||
getVisibleChildNotes() {
|
getVisibleChildNotes() {
|
||||||
return this.getChildBranches()
|
return this.getVisibleChildBranches()
|
||||||
.filter(branch => !branch.isHidden)
|
.map(branch => branch.getNote());
|
||||||
.map(branch => branch.getNote())
|
|
||||||
.filter(childNote => !childNote.isLabelTruthy('shareHiddenFromTree'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
|
@ -75,11 +75,11 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if (subRoot.hasVisibleChildren()) { %>
|
<% if (subRoot.note.hasVisibleChildren()) { %>
|
||||||
<button id="toggleMenuButton"></button>
|
<button id="toggleMenuButton"></button>
|
||||||
|
|
||||||
<nav id="menu">
|
<nav id="menu">
|
||||||
<%- include('tree_item', {note: subRoot, activeNote: note}) %>
|
<%- include('tree_item', {note: subRoot.note, branch: subRoot.branch, activeNote: note}) %>
|
||||||
</nav>
|
</nav>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
<p>
|
<p>
|
||||||
|
<% const titleWithPrefix = (branch.prefix ? `${branch.prefix} - ` : '') + note.title; %>
|
||||||
|
|
||||||
<% if (activeNote.noteId === note.noteId) { %>
|
<% if (activeNote.noteId === note.noteId) { %>
|
||||||
<strong><%= note.title %></strong>
|
<strong><%= titleWithPrefix %></strong>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<a class="type-<%= note.type %>" href="./<%= note.shareId %>"><%= note.title %></a>
|
<a class="type-<%= note.type %>" href="./<%= note.shareId %>"><%= titleWithPrefix %></a>
|
||||||
<% } %>
|
<% } %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% if (note.hasChildren()) { %>
|
<% if (note.hasChildren()) { %>
|
||||||
<ul>
|
<ul>
|
||||||
<% note.getVisibleChildNotes().forEach(function (childNote) { %>
|
<% note.getVisibleChildBranches().forEach(function (branch) { %>
|
||||||
<li>
|
<li>
|
||||||
<%- include('tree_item', {note: childNote}) %>
|
<%- include('tree_item', {branch: branch, note: branch.getNote()}) %>
|
||||||
</li>
|
</li>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user