feat: search protected notes text
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#notes-column.sn-component.section.notes(aria-label='Notes')
|
||||
.content
|
||||
#notes-title-bar.section-title-bar
|
||||
.padded
|
||||
.p-4.pt-0
|
||||
.section-title-bar-header
|
||||
.sk-h2.font-semibold.title {{self.state.panelTitle}}
|
||||
.sk-button.contrast.wide(
|
||||
@@ -19,11 +19,18 @@
|
||||
placeholder='Search',
|
||||
select-on-focus='true',
|
||||
title='Searches notes in the currently selected tag'
|
||||
)
|
||||
)
|
||||
#search-clear-button(
|
||||
ng-click='self.clearFilterText();',
|
||||
ng-show='self.state.noteFilter.text'
|
||||
) ✕
|
||||
label.sk-horizontal-group.tight.mt-3
|
||||
input(
|
||||
type="checkbox"
|
||||
ng-checked="self.state.noteFilter.includeProtectedNoteText"
|
||||
ng-on-click="self.onIncludeProtectedNoteTextChange($event)"
|
||||
)
|
||||
p.capitalize Include protected contents
|
||||
no-account-warning(
|
||||
application='self.application'
|
||||
app-state='self.appState'
|
||||
|
||||
@@ -31,7 +31,10 @@ type NotesState = {
|
||||
hideNotePreview?: boolean
|
||||
hideDate?: boolean
|
||||
hideTags: boolean
|
||||
noteFilter: { text: string }
|
||||
noteFilter: {
|
||||
text: string;
|
||||
includeProtectedNoteText: boolean;
|
||||
}
|
||||
mutable: { showMenu: boolean }
|
||||
completedFullSync: boolean
|
||||
[PrefKey.TagsPanelWidth]?: number
|
||||
@@ -125,7 +128,10 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesState> {
|
||||
renderedNotes: [],
|
||||
renderedNotesTags: [],
|
||||
mutable: { showMenu: false },
|
||||
noteFilter: { text: '' },
|
||||
noteFilter: {
|
||||
text: '',
|
||||
includeProtectedNoteText: false
|
||||
},
|
||||
panelTitle: '',
|
||||
completedFullSync: false,
|
||||
hideTags: true,
|
||||
@@ -149,6 +155,18 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesState> {
|
||||
}
|
||||
}
|
||||
|
||||
async onIncludeProtectedNoteTextChange(event: Event) {
|
||||
if (this.state.noteFilter.includeProtectedNoteText) {
|
||||
this.state.noteFilter.includeProtectedNoteText = false;
|
||||
} else {
|
||||
event.preventDefault();
|
||||
if (await this.application.authorizeSearchingProtectedNotesText()) {
|
||||
this.state.noteFilter.includeProtectedNoteText = true;
|
||||
}
|
||||
}
|
||||
this.flushUI();
|
||||
}
|
||||
|
||||
/** @template */
|
||||
public get activeEditorNote() {
|
||||
return this.appState?.getActiveEditor()?.note;
|
||||
@@ -330,17 +348,16 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesState> {
|
||||
private reloadNotesDisplayOptions() {
|
||||
const tag = this.appState.selectedTag;
|
||||
const searchText = this.getState().noteFilter.text.toLowerCase();
|
||||
const searchQuery = searchText ? {
|
||||
query: searchText,
|
||||
includeProtectedNoteText: false
|
||||
} : undefined;
|
||||
const criteria = NotesDisplayCriteria.Create({
|
||||
sortProperty: this.state.sortBy! as CollectionSort,
|
||||
sortDirection: this.state.sortReverse! ? 'asc' : 'dsc',
|
||||
tags: tag ? [tag] : [],
|
||||
includeArchived: this.getState().showArchived!,
|
||||
includePinned: !this.getState().hidePinned!,
|
||||
searchQuery: searchQuery
|
||||
searchQuery: {
|
||||
query: searchText ?? '',
|
||||
includeProtectedNoteText: this.state.noteFilter.includeProtectedNoteText
|
||||
}
|
||||
});
|
||||
this.application!.setNotesDisplayCriteria(criteria);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user