diff --git a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts index 777c92e07..23c3d810a 100644 --- a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts +++ b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts @@ -128,7 +128,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy { @Input() set filterRules (value: FilterRule[]) { this._filterRules = value - + this.documentTypeSelectionModel.clear(false) this.tagSelectionModel.clear(false) this.correspondentSelectionModel.clear(false) @@ -290,8 +290,12 @@ export class FilterEditorComponent implements OnInit, OnDestroy { distinctUntilChanged() ).subscribe(text => { this._textFilter = text + this.documentService.searchQuery = text this.updateRules() }) + + if (this._textFilter) this.documentService.searchQuery = this._textFilter + } ngOnDestroy() { diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.ts index 40dbc64f7..712b0492f 100644 --- a/src-ui/src/app/services/rest/document.service.ts +++ b/src-ui/src/app/services/rest/document.service.ts @@ -39,6 +39,8 @@ export interface SelectionData { }) export class DocumentService extends AbstractPaperlessService { + private _searchQuery: string + constructor(http: HttpClient, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private tagService: TagService) { super(http, 'documents') } @@ -92,6 +94,7 @@ export class DocumentService extends AbstractPaperlessService getPreviewUrl(id: number, original: boolean = false): string { let url = this.getResourceUrl(id, 'preview') + if (this._searchQuery) url += `#search="${this._searchQuery}"` if (original) { url += "?original=true" } @@ -138,4 +141,8 @@ export class DocumentService extends AbstractPaperlessService return this.http.post(this.getResourceUrl(null, 'bulk_download'), {"documents": ids, "content": content}, { responseType: 'blob' }) } + public set searchQuery(query: string) { + this._searchQuery = query + } + }