Suppport search term PDF open parameter

This commit is contained in:
Michael Shamoon
2021-04-03 13:10:39 -07:00
parent c9d76322eb
commit f7aa351bc9
2 changed files with 17 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ import { DocumentTypeService } from './document-type.service';
import { TagService } from './tag.service';
import { FILTER_RULE_TYPES } from 'src/app/data/filter-rule-type';
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions';
import { ActivatedRoute } from '@angular/router';
export const DOCUMENT_SORT_FIELDS = [
{ field: 'archive_serial_number', name: $localize`ASN` },
@@ -39,8 +40,14 @@ export interface SelectionData {
})
export class DocumentService extends AbstractPaperlessService<PaperlessDocument> {
constructor(http: HttpClient, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private tagService: TagService) {
private searchQuery: string
constructor(http: HttpClient, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private tagService: TagService, private route: ActivatedRoute) {
super(http, 'documents')
this.route.queryParamMap.subscribe(paramMap => {
this.searchQuery = paramMap.get('query')
})
}
private filterRulesToQueryParams(filterRules: FilterRule[]) {
@@ -92,6 +99,7 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
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 +146,8 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
return this.http.post(this.getResourceUrl(null, 'bulk_download'), {"documents": ids, "content": content}, { responseType: 'blob' })
}
public setSearchQuery(query: string) {
this.searchQuery = query
}
}