From 17073096cfc261c17f58a91117baa544b9a21c8b Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 31 Jan 2021 20:07:56 +0100 Subject: [PATCH] disable property widgets if not applicable --- .../app/widgets/type_property_widgets/file_properties.js | 6 +++++- .../app/widgets/type_property_widgets/image_properties.js | 6 +++++- .../app/widgets/type_property_widgets/note_properties.js | 6 +++++- .../app/widgets/type_property_widgets/search_definition.js | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/public/app/widgets/type_property_widgets/file_properties.js b/src/public/app/widgets/type_property_widgets/file_properties.js index 4bd58932a..6af0816e1 100644 --- a/src/public/app/widgets/type_property_widgets/file_properties.js +++ b/src/public/app/widgets/type_property_widgets/file_properties.js @@ -57,9 +57,13 @@ const TPL = ` export default class FilePropertiesWidget extends TabAwareWidget { static getType() { return "file"; } + isEnabled() { + return this.note && this.note.type === 'file'; + } + renderTitle(note) { return { - show: note.type === 'file', + show: this.isEnabled(), activate: true, $title: 'File' }; diff --git a/src/public/app/widgets/type_property_widgets/image_properties.js b/src/public/app/widgets/type_property_widgets/image_properties.js index d08cf6a14..0359d24ad 100644 --- a/src/public/app/widgets/type_property_widgets/image_properties.js +++ b/src/public/app/widgets/type_property_widgets/image_properties.js @@ -37,9 +37,13 @@ const TPL = ` export default class ImagePropertiesWidget extends TabAwareWidget { static getType() { return "image"; } + isEnabled() { + return this.note && this.note.type === 'image'; + } + renderTitle(note) { return { - show: note.type === 'image', + show: this.isEnabled(), activate: true, $title: 'Image' }; diff --git a/src/public/app/widgets/type_property_widgets/note_properties.js b/src/public/app/widgets/type_property_widgets/note_properties.js index e5a9f1174..6049246cb 100644 --- a/src/public/app/widgets/type_property_widgets/note_properties.js +++ b/src/public/app/widgets/type_property_widgets/note_properties.js @@ -15,9 +15,13 @@ const TPL = ` export default class NotePropertiesWidget extends TabAwareWidget { static getType() { return "note-properties"; } + isEnabled() { + return this.note && !!this.note.getLabelValue('pageUrl'); + } + renderTitle(note) { return { - show: !!note.getLabelValue('pageUrl'), + show: this.isEnabled(), activate: true, $title: 'Info' }; diff --git a/src/public/app/widgets/type_property_widgets/search_definition.js b/src/public/app/widgets/type_property_widgets/search_definition.js index ed15c4eda..4df0cef68 100644 --- a/src/public/app/widgets/type_property_widgets/search_definition.js +++ b/src/public/app/widgets/type_property_widgets/search_definition.js @@ -184,9 +184,13 @@ for (const clazz of [ export default class SearchDefinitionWidget extends TabAwareWidget { static getType() { return "search"; } + isEnabled() { + return this.note && this.note.type === 'search'; + } + renderTitle(note) { return { - show: note.type === 'search', + show: this.isEnabled(), activate: true, $title: 'Search' };