diff --git a/src/public/app/layouts/desktop_main_window_layout.js b/src/public/app/layouts/desktop_main_window_layout.js
index f7381ea96..82c2541b6 100644
--- a/src/public/app/layouts/desktop_main_window_layout.js
+++ b/src/public/app/layouts/desktop_main_window_layout.js
@@ -27,6 +27,7 @@ import EditedNotesWidget from "../widgets/collapsible_widgets/edited_notes.js";
import CollapsibleSectionContainer from "../widgets/collapsible_section_container.js";
import PromotedAttributesWidget from "../widgets/promoted_attributes.js";
import InheritedAttributesWidget from "../widgets/inherited_attribute_list.js";
+import NoteListWidget from "../widgets/note_list.js";
const RIGHT_PANE_CSS = `
+
+`;
+
+export default class NoteListWidget extends TabAwareWidget {
+ isEnabled() {
+ return super.isEnabled() && !this.tabContext.autoBookDisabled && (
+ ['book', 'search'].includes(this.note.type)
+ || (this.note.type === 'text' && this.note.hasChildren())
+ );
+ }
+
+ doRender() {
+ this.$widget = $(TPL);
+ this.contentSized();
+ }
+
+ async refreshWithNote(note) {
+ const noteListRenderer = new NoteListRenderer(note, note.getChildNoteIds());
+
+ this.$widget.empty().append(await noteListRenderer.renderList());
+ }
+
+ autoBookDisabledEvent({tabContext}) {
+ if (this.isTab(tabContext.tabId)) {
+ this.refresh();
+ }
+ }
+}
diff --git a/src/public/app/widgets/type_widgets/book.js b/src/public/app/widgets/type_widgets/book.js
index 6fda5cb60..aca93d3c3 100644
--- a/src/public/app/widgets/type_widgets/book.js
+++ b/src/public/app/widgets/type_widgets/book.js
@@ -4,34 +4,23 @@ import TypeWidget from "./type_widget.js";
const TPL = `
-
+
This note of type Book doesn't have any child notes so there's nothing to display. See
wiki for details.
-
-
+
+
+ This note doesn't have any content so we display its children.
+
Click
here if you want to add some text.
+
`;
export default class BookTypeWidget extends TypeWidget {
@@ -39,57 +28,19 @@ export default class BookTypeWidget extends TypeWidget {
doRender() {
this.$widget = $(TPL);
- this.$content = this.$widget.find('.note-detail-book-content');
- this.$help = this.$widget.find('.note-detail-book-help');
+ this.contentSized();
+ this.$helpNoChildren = this.$widget.find('.note-detail-book-empty-help');
+
+ this.$helpAutoBook = this.$widget.find('.note-detail-book-auto-help');
+ this.$helpAutoBook.find('a').on('click', () => {
+ this.tabContext.autoBookDisabled = true;
+
+ this.triggerEvent('autoBookDisabled', {tabContext: this.tabContext});
+ });
}
async doRefresh(note) {
- this.$content.empty();
- this.$help.hide();
-
- if (this.isAutoBook()) {
- const $addTextLink = $('
here').on('click', () => {
- this.tabContext.autoBookDisabled = true;
-
- this.triggerEvent('autoBookDisabled', {tabContext: this.tabContext});
- });
-
- this.$content.append($('
')
- .append(`This note doesn't have any content so we display its children.
Click `)
- .append($addTextLink)
- .append(' if you want to add some text.'));
- }
-
- const noteListRenderer = new NoteListRenderer(note, note.getChildNoteIds());
-
- this.$content.append(await noteListRenderer.renderList());
- }
-
- /** @return {boolean} true if this is "auto book" activated (empty text note) and not explicit book note */
- isAutoBook() {
- return this.note.type !== 'book';
- }
-
- getDefaultZoomLevel() {
- if (this.isAutoBook()) {
- const w = this.$widget.width();
-
- if (w <= 600) {
- return 1;
- } else if (w <= 900) {
- return 2;
- } else if (w <= 1300) {
- return 3;
- } else {
- return 4;
- }
- }
- else {
- return 1;
- }
- }
-
- cleanup() {
- this.$content.empty();
+ this.$helpNoChildren.toggle(!this.note.hasChildren());
+ this.$helpAutoBook.toggle(this.note.type !== 'book');
}
}