sidebar & widget state management WIP

This commit is contained in:
zadam
2019-08-15 10:04:03 +02:00
parent 61520bc3b3
commit 59da25ef55
9 changed files with 286 additions and 97 deletions

View File

@@ -30,9 +30,13 @@ class LinkMapWidget {
constructor(ctx, $widget) {
this.ctx = ctx;
this.$widget = $widget;
this.$widget.on('show.bs.collapse', () => this.renderBody());
this.$widget.on('show.bs.collapse', () => this.ctx.stateChanged());
this.$widget.on('hide.bs.collapse', () => this.ctx.stateChanged());
this.$title = this.$widget.find('.widget-title');
this.$title.text("Link map");
this.$headerActions = this.$widget.find('.widget-header-actions');
this.$bodyWrapper = this.$widget.find('.body-wrapper');
const $showFullButton = $("<a>").append("show full").addClass('widget-header-action');
$showFullButton.click(() => {
@@ -43,6 +47,10 @@ class LinkMapWidget {
}
async renderBody() {
if (!this.isVisible()) {
return;
}
const $body = this.$widget.find('.card-body');
$body.html(TPL);
@@ -225,6 +233,17 @@ class LinkMapWidget {
noteIdToId(noteId) {
return "link-map-note-" + noteId;
}
getWidgetState() {
return {
id: 'attributes',
visible: this.isVisible()
};
}
isVisible() {
return this.$bodyWrapper.is(":visible");
}
}
export default LinkMapWidget;