diff --git a/src/public/javascripts/widgets/attributes.js b/src/public/javascripts/widgets/attributes.js index 1b1585cf5..de069f948 100644 --- a/src/public/javascripts/widgets/attributes.js +++ b/src/public/javascripts/widgets/attributes.js @@ -5,17 +5,15 @@ import messagingService from "../services/messaging.js"; import StandardWidget from "./standard_widget.js"; class AttributesWidget extends StandardWidget { - constructor(ctx, state) { - super(ctx, state); - - this.$title.text("Attributes"); + getWidgetTitle() { return "Attributes"; } + getHeaderActions() { const $showFullButton = $("").append("show dialog").addClass('widget-header-action'); $showFullButton.click(() => { attributesDialog.showDialog(); }); - this.$headerActions.append($showFullButton); + return [$showFullButton]; } async doRenderBody() { diff --git a/src/public/javascripts/widgets/link_map.js b/src/public/javascripts/widgets/link_map.js index b9d835783..625270a8c 100644 --- a/src/public/javascripts/widgets/link_map.js +++ b/src/public/javascripts/widgets/link_map.js @@ -24,21 +24,15 @@ const linkOverlays = [ ]; class LinkMapWidget extends StandardWidget { - /** - * @param {TabContext} ctx - * @param {object} state - */ - constructor(ctx, state) { - super(ctx, state); - - this.$title.text("Link map"); + getWidgetTitle() { return "Link map"; } + getHeaderActions() { const $showFullButton = $("").append("show full").addClass('widget-header-action'); $showFullButton.click(() => { linkMapDialog.showDialog(); }); - this.$headerActions.append($showFullButton); + return [$showFullButton]; } async doRenderBody() { diff --git a/src/public/javascripts/widgets/note_info.js b/src/public/javascripts/widgets/note_info.js index f036e1f3e..4ad81b8af 100644 --- a/src/public/javascripts/widgets/note_info.js +++ b/src/public/javascripts/widgets/note_info.js @@ -26,15 +26,7 @@ const TPL = ` `; class NoteInfoWidget extends StandardWidget { - /** - * @param {TabContext} ctx - * @param {object} state - */ - constructor(ctx, state) { - super(ctx, state); - - this.$title.text("Note info"); - } + getWidgetTitle() { return "Note info"; } async doRenderBody() { this.$body.html(TPL); diff --git a/src/public/javascripts/widgets/note_revisions.js b/src/public/javascripts/widgets/note_revisions.js index dccc59353..7b7cb38a7 100644 --- a/src/public/javascripts/widgets/note_revisions.js +++ b/src/public/javascripts/widgets/note_revisions.js @@ -7,15 +7,7 @@ const TPL = ` `; class NoteRevisionsWidget extends StandardWidget { - /** - * @param {TabContext} ctx - * @param {object} state - */ - constructor(ctx, state) { - super(ctx, state); - - this.$title.text("Note revisions"); - } + getWidgetTitle() { return "Note revisions"; } async doRenderBody() { const revisionItems = await server.get(`notes/${this.ctx.note.noteId}/revisions`); diff --git a/src/public/javascripts/widgets/standard_widget.js b/src/public/javascripts/widgets/standard_widget.js index 6bd77e492..fea570439 100644 --- a/src/public/javascripts/widgets/standard_widget.js +++ b/src/public/javascripts/widgets/standard_widget.js @@ -41,9 +41,15 @@ class StandardWidget { this.$widget.on('shown.bs.collapse', () => this.ctx.stateChanged()); this.$widget.on('hidden.bs.collapse', () => this.ctx.stateChanged()); this.$title = this.$widget.find('.widget-title'); + this.$title.text(this.getWidgetTitle()); this.$headerActions = this.$widget.find('.widget-header-actions'); + this.$headerActions.append(...this.getHeaderActions()); } + getWidgetTitle() { return "Untitled widget"; } + + getHeaderActions() { return []; } + async renderBody() { if (!this.isVisible() || this.rendered) { return; diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 47ee49315..3a09634d5 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -134,6 +134,7 @@ ul.fancytree-container { } .note-detail-sidebar .widget-header-actions { + padding-right: 10px; } .note-detail-sidebar .widget-header-action {