diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts index 5a4521e12..a038c9a31 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.ts @@ -81,7 +81,10 @@ export class AppFrameComponent { search() { this.closeMenu() this.list.quickFilter([ - { rule_type: FILTER_FULLTEXT_QUERY, value: this.searchField.value }, + { + rule_type: FILTER_FULLTEXT_QUERY, + value: (this.searchField.value as string).trim(), + }, ]) } diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts index f9135d27f..ea1fa831d 100644 --- a/src-ui/src/app/components/document-list/document-list.component.ts +++ b/src-ui/src/app/components/document-list/document-list.component.ts @@ -151,8 +151,9 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit { ngAfterViewInit(): void { this.filterEditor.filterRulesChange.subscribe({ - next: (rules) => { - const params = this.documentService.queryParams + next: (filterRules) => { + const params = + this.documentService.filterRulesToQueryParams(filterRules) // if we were on a saved view we navigate 'away' to /documents let base = [] diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts index e33dea1d6..fa07649af 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -249,20 +249,11 @@ export class DocumentListViewService { } quickFilter(filterRules: FilterRule[]) { - this._activeSavedViewId = null - this.activeListViewState.filterRules = filterRules - this.activeListViewState.currentPage = 1 - if (isFullTextFilterRule(filterRules)) { - this.activeListViewState.sortField = 'score' - this.activeListViewState.sortReverse = false - } - this.reduceSelectionToFilter() - this.saveDocumentListView() - if (this.router.url == '/documents') { - this.reload() - } else { - this.router.navigate(['documents']) - } + const params = this.documentService.filterRulesToQueryParams(filterRules) + this.router.navigate(['/documents'], { + relativeTo: this.route, + queryParams: params, + }) } getLastPage(): number { diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.ts index 9694d63b0..d06282bb8 100644 --- a/src-ui/src/app/services/rest/document.service.ts +++ b/src-ui/src/app/services/rest/document.service.ts @@ -47,7 +47,6 @@ export interface SelectionData { }) export class DocumentService extends AbstractPaperlessService { private _searchQuery: string - public queryParams: Object = {} constructor( http: HttpClient, @@ -58,7 +57,7 @@ export class DocumentService extends AbstractPaperlessService super(http, 'documents') } - private filterRulesToQueryParams(filterRules: FilterRule[]): Object { + public filterRulesToQueryParams(filterRules: FilterRule[]): Object { if (filterRules) { let params = {} for (let rule of filterRules) { @@ -102,13 +101,12 @@ export class DocumentService extends AbstractPaperlessService filterRules?: FilterRule[], extraParams = {} ): Observable> { - this.queryParams = this.filterRulesToQueryParams(filterRules) return this.list( page, pageSize, sortField, sortReverse, - Object.assign(extraParams, this.queryParams) + Object.assign(extraParams, this.filterRulesToQueryParams(filterRules)) ).pipe( map((results) => { results.results.forEach((doc) => this.addObservablesToDocument(doc))