mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
expand all / collapse all will re-render list instead of doing that manually
This commit is contained in:
parent
b70ee742e8
commit
bb0ee0b36c
@ -161,30 +161,20 @@ class NoteListRenderer {
|
|||||||
this.$noteList.find('.grid-view-button').on('click', () => this.toggleViewType('grid'));
|
this.$noteList.find('.grid-view-button').on('click', () => this.toggleViewType('grid'));
|
||||||
|
|
||||||
this.$noteList.find('.expand-children-button').on('click', async () => {
|
this.$noteList.find('.expand-children-button').on('click', async () => {
|
||||||
for (let i = 1; i < 30; i++) { // protection against infinite cycle
|
|
||||||
const $unexpandedCards = this.$noteList.find('.note-book-card:not(.expanded)');
|
|
||||||
|
|
||||||
if ($unexpandedCards.length === 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.toggleCards($unexpandedCards, true);
|
|
||||||
|
|
||||||
if (!this.parentNote.hasLabel('expanded')) {
|
if (!this.parentNote.hasLabel('expanded')) {
|
||||||
await attributeService.addLabel(this.parentNote.noteId, 'expanded');
|
await attributeService.addLabel(this.parentNote.noteId, 'expanded');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
await this.renderList();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$noteList.find('.collapse-all-button').on('click', async () => {
|
this.$noteList.find('.collapse-all-button').on('click', async () => {
|
||||||
const $expandedCards = this.$noteList.find('.note-book-card.expanded');
|
|
||||||
|
|
||||||
await this.toggleCards($expandedCards, false);
|
|
||||||
|
|
||||||
// owned is important - we shouldn't remove inherited expanded labels
|
// owned is important - we shouldn't remove inherited expanded labels
|
||||||
for (const expandedAttr of this.parentNote.getOwnedLabels('expanded')) {
|
for (const expandedAttr of this.parentNote.getOwnedLabels('expanded')) {
|
||||||
await attributeService.removeAttributeById(this.parentNote.noteId, expandedAttr.attributeId);
|
await attributeService.removeAttributeById(this.parentNote.noteId, expandedAttr.attributeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.renderList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,16 +243,6 @@ class NoteListRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleCards(cards, expand) {
|
|
||||||
for (const card of cards) {
|
|
||||||
const $card = $(card);
|
|
||||||
const noteId = $card.attr('data-note-id');
|
|
||||||
const note = await treeCache.getNote(noteId);
|
|
||||||
|
|
||||||
await this.toggleContent($card, note, expand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: we should also render (promoted) attributes
|
// TODO: we should also render (promoted) attributes
|
||||||
// FIXME: showing specific path might be necessary because of a match in the patch
|
// FIXME: showing specific path might be necessary because of a match in the patch
|
||||||
async renderNote(note, expand = false) {
|
async renderNote(note, expand = false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user