mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix quick filtering
This commit is contained in:
parent
7149d407cd
commit
0a29f51862
@ -81,7 +81,10 @@ export class AppFrameComponent {
|
|||||||
search() {
|
search() {
|
||||||
this.closeMenu()
|
this.closeMenu()
|
||||||
this.list.quickFilter([
|
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 {
|
ngAfterViewInit(): void {
|
||||||
this.filterEditor.filterRulesChange.subscribe({
|
this.filterEditor.filterRulesChange.subscribe({
|
||||||
next: (rules) => {
|
next: (filterRules) => {
|
||||||
const params = this.documentService.queryParams
|
const params =
|
||||||
|
this.documentService.filterRulesToQueryParams(filterRules)
|
||||||
|
|
||||||
// if we were on a saved view we navigate 'away' to /documents
|
// if we were on a saved view we navigate 'away' to /documents
|
||||||
let base = []
|
let base = []
|
||||||
|
@ -249,20 +249,11 @@ export class DocumentListViewService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
quickFilter(filterRules: FilterRule[]) {
|
quickFilter(filterRules: FilterRule[]) {
|
||||||
this._activeSavedViewId = null
|
const params = this.documentService.filterRulesToQueryParams(filterRules)
|
||||||
this.activeListViewState.filterRules = filterRules
|
this.router.navigate(['/documents'], {
|
||||||
this.activeListViewState.currentPage = 1
|
relativeTo: this.route,
|
||||||
if (isFullTextFilterRule(filterRules)) {
|
queryParams: params,
|
||||||
this.activeListViewState.sortField = 'score'
|
})
|
||||||
this.activeListViewState.sortReverse = false
|
|
||||||
}
|
|
||||||
this.reduceSelectionToFilter()
|
|
||||||
this.saveDocumentListView()
|
|
||||||
if (this.router.url == '/documents') {
|
|
||||||
this.reload()
|
|
||||||
} else {
|
|
||||||
this.router.navigate(['documents'])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastPage(): number {
|
getLastPage(): number {
|
||||||
|
@ -47,7 +47,6 @@ export interface SelectionData {
|
|||||||
})
|
})
|
||||||
export class DocumentService extends AbstractPaperlessService<PaperlessDocument> {
|
export class DocumentService extends AbstractPaperlessService<PaperlessDocument> {
|
||||||
private _searchQuery: string
|
private _searchQuery: string
|
||||||
public queryParams: Object = {}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
http: HttpClient,
|
http: HttpClient,
|
||||||
@ -58,7 +57,7 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
|||||||
super(http, 'documents')
|
super(http, 'documents')
|
||||||
}
|
}
|
||||||
|
|
||||||
private filterRulesToQueryParams(filterRules: FilterRule[]): Object {
|
public filterRulesToQueryParams(filterRules: FilterRule[]): Object {
|
||||||
if (filterRules) {
|
if (filterRules) {
|
||||||
let params = {}
|
let params = {}
|
||||||
for (let rule of filterRules) {
|
for (let rule of filterRules) {
|
||||||
@ -102,13 +101,12 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
|||||||
filterRules?: FilterRule[],
|
filterRules?: FilterRule[],
|
||||||
extraParams = {}
|
extraParams = {}
|
||||||
): Observable<Results<PaperlessDocument>> {
|
): Observable<Results<PaperlessDocument>> {
|
||||||
this.queryParams = this.filterRulesToQueryParams(filterRules)
|
|
||||||
return this.list(
|
return this.list(
|
||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
sortField,
|
sortField,
|
||||||
sortReverse,
|
sortReverse,
|
||||||
Object.assign(extraParams, this.queryParams)
|
Object.assign(extraParams, this.filterRulesToQueryParams(filterRules))
|
||||||
).pipe(
|
).pipe(
|
||||||
map((results) => {
|
map((results) => {
|
||||||
results.results.forEach((doc) => this.addObservablesToDocument(doc))
|
results.results.forEach((doc) => this.addObservablesToDocument(doc))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user