mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Fix quick filtering
This commit is contained in:
		| @@ -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(), | ||||
|       }, | ||||
|     ]) | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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 = [] | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -47,7 +47,6 @@ export interface SelectionData { | ||||
| }) | ||||
| export class DocumentService extends AbstractPaperlessService<PaperlessDocument> { | ||||
|   private _searchQuery: string | ||||
|   public queryParams: Object = {} | ||||
|  | ||||
|   constructor( | ||||
|     http: HttpClient, | ||||
| @@ -58,7 +57,7 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument> | ||||
|     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<PaperlessDocument> | ||||
|     filterRules?: FilterRule[], | ||||
|     extraParams = {} | ||||
|   ): Observable<Results<PaperlessDocument>> { | ||||
|     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)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon