feat(tree): display number of children if subtree is hidden

This commit is contained in:
Elian Doran 2026-01-09 16:54:04 +02:00
parent acc8cee7cd
commit 92e6a29e70
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,10 @@
.note-indicator-icon.subtree-hidden-badge {
font-family: inherit !important;
margin-inline-start: 0.5em;
background: var(--left-pane-item-action-button-background);
color: var(--left-pane-item-action-button-color);
padding: 0.25em;
border-radius: 0.5em;
font-size: 0.7rem;
font-weight: normal;
}

View File

@ -3,13 +3,13 @@ import "jquery.fancytree/dist/modules/jquery.fancytree.dnd5.js";
import "jquery.fancytree/dist/modules/jquery.fancytree.clones.js";
import "jquery.fancytree/dist/modules/jquery.fancytree.filter.js";
import "../stylesheets/tree.css";
import "./note_tree.css";
import appContext, { type CommandListenerData, type EventData } from "../components/app_context.js";
import type { SetNoteOpts } from "../components/note_context.js";
import type { TouchBarItem } from "../components/touch_bar.js";
import type FBranch from "../entities/fbranch.js";
import type FNote from "../entities/fnote.js";
import type { NoteType } from "../entities/fnote.js";
import contextMenu from "../menus/context_menu.js";
import type { TreeCommandNames } from "../menus/tree_context_menu.js";
import branchService from "../services/branches.js";
@ -1887,5 +1887,11 @@ function buildEnhanceTitle() {
$sharedIndicator.attr("title", tooltipText);
$span.find(".fancytree-title").append($sharedIndicator);
}
// Add a badge with the number of items if it hides children.
if (note.hasLabel("subtreeHidden")) {
const $badge = $(`<span class="note-indicator-icon subtree-hidden-badge">${note.getChildNoteIds().length}</span>`);
$span.find(".fancytree-title").append($badge);
}
};
}