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

@@ -31,11 +31,19 @@ class NoteInfoWidget {
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("Note info");
this.$bodyWrapper = this.$widget.find('.body-wrapper');
}
async renderBody() {
if (!this.isVisible()) {
return;
}
const $body = this.$widget.find('.card-body');
$body.html(TPL);
@@ -60,6 +68,17 @@ class NoteInfoWidget {
this.renderBody();
}
}
getWidgetState() {
return {
id: 'attributes',
visible: this.isVisible()
};
}
isVisible() {
return this.$bodyWrapper.is(":visible");
}
}
export default NoteInfoWidget;