fix collapsing/expanding the book note

This commit is contained in:
zadam 2021-09-29 13:19:21 +02:00
parent c2d35dac4d
commit d975acc99a
4 changed files with 14 additions and 6 deletions

View File

@ -53,8 +53,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
this.$importNoteButton = this.$widget.find('.import-files-button');
this.$importNoteButton.on("click", () => import('../../dialogs/import.js').then(d => d.showDialog(this.noteId)));
this.$widget.on('click', '.dropdown-item',
() => this.$widget.find('.dropdown-toggle').dropdown('toggle'));
this.$widget.on('click', '.dropdown-item', () => this.$widget.find('.dropdown-menu').dropdown('toggle'));
this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
}

View File

@ -10,8 +10,8 @@ export default class ProtectedSessionStatusWidget extends ButtonWidget {
updateSettings() {
this.settings.icon = protectedSessionHolder.isProtectedSessionAvailable()
? "bx-shield-quarter"
: "bx-log-in";
? "bx-check-shield"
: "bx-shield-quarter";
this.settings.title = protectedSessionHolder.isProtectedSessionAvailable()
? "Protected session is active. Click to leave protected session."

View File

@ -66,12 +66,17 @@ export default class NoteListWidget extends NoteContextAwareWidget {
}
async refresh() {
this.$content.empty();
this.shownNoteId = null;
await super.refresh();
}
async refreshNoteListEvent({noteId}) {
if (this.isNote(noteId)) {
await this.renderNoteList(this.note);
}
}
/**
* We have this event so that we evaluate intersection only after note detail is loaded.
* If it's evaluated before note detail then it's clearly intersected (visible) although after note detail load
@ -94,7 +99,7 @@ export default class NoteListWidget extends NoteContextAwareWidget {
}
entitiesReloadedEvent({loadResults}) {
if (loadResults.getAttributes().find(attr => attr.noteId === this.noteId && attr.name === 'viewType')) {
if (loadResults.getAttributes().find(attr => attr.noteId === this.noteId && ['viewType', 'expanded'].includes(attr.name))) {
this.shownNoteId = null; // force render
this.checkRenderStatus();

View File

@ -75,6 +75,8 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
if (!this.note.hasLabel('expanded')) {
await attributeService.addLabel(this.noteId, 'expanded');
}
this.triggerCommand('refreshNoteList', {noteId: this.noteId});
});
this.$collapseAllButton = this.$widget.find('.collapse-all-button');
@ -83,6 +85,8 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
for (const expandedAttr of this.note.getOwnedLabels('expanded')) {
await attributeService.removeAttributeById(this.noteId, expandedAttr.attributeId);
}
this.triggerCommand('refreshNoteList', {noteId: this.noteId});
});
}