import TabAwareWidget from "./tab_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 TabAwareWidget { isEnabled() { return super.isEnabled() && this.note.type === 'search'; } doRender() { this.$widget = $(TPL); 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'); this.contentSized(); } 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({tabId}) { if (!this.isTab(tabId)) { return; } this.refresh(); } notesReloadedEvent({noteIds}) { if (noteIds.includes(this.noteId)) { this.refresh(); } } }