diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index d1580ab41..46307bbf0 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -22,7 +22,8 @@ const NOTE_TYPE_ICONS = { "canvas": "bx bx-pen", "web-view": "bx bx-globe-alt", "launcher": "bx bx-link", - "doc": "bx bxs-file-doc" + "doc": "bx bxs-file-doc", + "content-widget": "bx bxs-widget" }; /** diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index f52f665f8..090d0be5c 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -26,7 +26,7 @@ import NoneTypeWidget from "./type_widgets/none.js"; import NoteMapTypeWidget from "./type_widgets/note_map.js"; import WebViewTypeWidget from "./type_widgets/web_view.js"; import DocTypeWidget from "./type_widgets/doc.js"; -import WidgetTypeWidget from "./type_widgets/widget.js"; +import ContentWidgetTypeWidget from "./type_widgets/widget.js"; const TPL = `
@@ -61,7 +61,7 @@ const typeWidgetClasses = { 'note-map': NoteMapTypeWidget, 'web-view': WebViewTypeWidget, 'doc': DocTypeWidget, - 'widget': WidgetTypeWidget + 'content-widget': ContentWidgetTypeWidget }; export default class NoteDetailWidget extends NoteContextAwareWidget { @@ -130,6 +130,10 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { if (!(this.type in this.typeWidgets)) { const clazz = typeWidgetClasses[this.type]; + if (!clazz) { + throw new Error(`Cannot find type widget for type '${this.type}'`); + } + const typeWidget = this.typeWidgets[this.type] = new clazz(); typeWidget.spacedUpdate = this.spacedUpdate; typeWidget.setParent(this); diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.js index 6cbd9667d..f40a19310 100644 --- a/src/public/app/widgets/note_type.js +++ b/src/public/app/widgets/note_type.js @@ -10,7 +10,7 @@ const NOTE_TYPES = [ { type: "note-map", mime: '', title: "Note Map", selectable: false }, { type: "launcher", mime: '', title: "Launcher", selectable: false }, { type: "doc", mime: '', title: "Doc", selectable: false }, - { type: "widget", mime: '', title: "Widget", selectable: false }, + { type: "content-widget", mime: '', title: "Widget", selectable: false }, { type: "text", mime: "text/html", title: "Text", selectable: true }, { type: "relation-map", mime: "application/json", title: "Relation Map", selectable: true }, diff --git a/src/public/app/widgets/type_widgets/widget.js b/src/public/app/widgets/type_widgets/widget.js index 88c0b15c8..9cac12438 100644 --- a/src/public/app/widgets/type_widgets/widget.js +++ b/src/public/app/widgets/type_widgets/widget.js @@ -2,8 +2,8 @@ import TypeWidget from "./type_widget.js"; const TPL = `
`; -export default class WidgetTypeWidget extends TypeWidget { - static getType() { return "widget"; } +export default class ContentWidgetTypeWidget extends TypeWidget { + static getType() { return "content-widget"; } doRender() { this.$widget = $(TPL); @@ -12,12 +12,12 @@ export default class WidgetTypeWidget extends TypeWidget { } async doRefresh(note) { - const widgetName = note.getLabelValue('widget'); + const contentWidget = note.getLabelValue('contentWidget'); - if (widgetName === 'optionsAppearance') { + if (contentWidget === 'optionsAppearance') { this.$widget.empty().append("HI!"); } else { - this.$widget.empty().append(`Unknown widget of type "${widgetName}"`); + this.$widget.empty().append(`Unknown widget of type "${contentWidget}"`); } } } diff --git a/src/services/note_types.js b/src/services/note_types.js index 2f52f2110..ef20b95d5 100644 --- a/src/services/note_types.js +++ b/src/services/note_types.js @@ -13,5 +13,5 @@ module.exports = [ 'web-view', 'launcher', 'doc', - 'widget' + 'content-widget' ]; diff --git a/src/services/special_notes.js b/src/services/special_notes.js index f285c5847..15bf85cdb 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -593,12 +593,12 @@ function createOptionNotes() { branchId: OPTIONS_APPEARANCE, noteId: OPTIONS_APPEARANCE, title: 'Appearance', - type: 'widget', + type: 'content-widget', content: '', parentNoteId: OPTIONS_ROOT }).note; - note.addLabel('widget', 'optionsAppearance'); + note.addLabel('contentWidget', 'optionsAppearance'); } }