import NoteContextAwareWidget from "./note_context_aware_widget.js"; import NoteListRenderer from "../services/note_list_renderer.js"; const TPL = `
No notes have been found for given search parameters.
Search has not been executed yet. Click on "Search" button above to see the results.
`; export default class SearchResultWidget extends NoteContextAwareWidget { isEnabled() { return super.isEnabled() && this.note.type === 'search'; } doRender() { this.$widget = $(TPL); this.contentSized(); this.$content = this.$widget.find('.search-result-widget-content'); this.$noResults = this.$widget.find('.search-no-results'); this.$notExecutedYet = this.$widget.find('.search-not-executed-yet'); } async refreshWithNote(note) { this.$content.empty(); this.$noResults.toggle(note.getChildNoteIds().length === 0 && !!note.searchResultsLoaded); this.$notExecutedYet.toggle(!note.searchResultsLoaded); const noteListRenderer = new NoteListRenderer(this.$content, note, note.getChildNoteIds(), true); await noteListRenderer.renderList(); } searchRefreshedEvent({ntxId}) { if (!this.isNoteContext(ntxId)) { return; } this.refresh(); } notesReloadedEvent({noteIds}) { if (noteIds.includes(this.noteId)) { this.refresh(); } } }