Notes/src/public/app/widgets/note_list.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

import TabAwareWidget from "./tab_aware_widget.js";
import NoteListRenderer from "../services/note_list_renderer.js";
const TPL = `
<div class="note-list-widget">
2020-11-26 23:00:27 +01:00
<style>
.note-list-widget {
flex-grow: 100000;
flex-shrink: 100000;
min-height: 0;
2020-12-13 20:13:57 +01:00
overflow: auto;
2020-11-26 23:00:27 +01:00
}
2020-12-13 23:27:42 +01:00
.note-list-widget .note-list {
padding: 10px;
}
2020-11-26 23:00:27 +01:00
</style>
<div class="note-list-widget-content">
</div>
</div>`;
export default class NoteListWidget extends TabAwareWidget {
isEnabled() {
2020-11-26 23:00:27 +01:00
return super.isEnabled() && (
['book', 'search'].includes(this.note.type)
|| (this.note.type === 'text' && this.note.hasChildren())
);
}
doRender() {
this.$widget = $(TPL);
2020-11-26 23:00:27 +01:00
this.$content = this.$widget.find('.note-list-widget-content');
this.contentSized();
}
async refreshWithNote(note) {
const noteListRenderer = new NoteListRenderer(note, note.getChildNoteIds());
2020-11-26 23:00:27 +01:00
this.$content.empty().append(await noteListRenderer.renderList());
}
autoBookDisabledEvent({tabContext}) {
if (this.isTab(tabContext.tabId)) {
this.refresh();
}
}
2020-11-26 23:00:27 +01:00
2020-12-17 21:19:52 +01:00
notesReloadedEvent({noteIds}) {
if (noteIds.includes(this.noteId)) {
2020-11-26 23:00:27 +01:00
this.refresh();
}
}
}