Handle page parameter on saved views

This commit is contained in:
Michael Shamoon
2022-08-05 23:35:13 -07:00
parent cdc7a5842e
commit b82a18721d
3 changed files with 33 additions and 16 deletions

View File

@@ -6,7 +6,7 @@ import {
ViewChild,
ViewChildren,
} from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { ActivatedRoute, convertToParamMap, Router } from '@angular/router'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { filter, first, map, Subject, switchMap, takeUntil } from 'rxjs'
import { FilterRule, isFullTextFilterRule } from 'src/app/data/filter-rule'
@@ -126,7 +126,11 @@ export class DocumentListComponent implements OnInit, OnDestroy {
this.router.navigate(['404'])
return
}
this.list.activateSavedView(view)
this.list.activateSavedViewWithQueryParams(
view,
convertToParamMap(this.route.snapshot.queryParams)
)
this.list.reload()
this.unmodifiedFilterRules = view.filter_rules
})
@@ -139,7 +143,13 @@ export class DocumentListComponent implements OnInit, OnDestroy {
.subscribe((queryParams) => {
if (queryParams.has('view')) {
// loading a saved view on /documents
this.loadViewConfig(parseInt(queryParams.get('view')))
this.savedViewService
.getCached(parseInt(queryParams.get('view')))
.pipe(first())
.subscribe((view) => {
this.list.activateSavedView(view)
this.list.reload()
})
} else {
this.list.activateSavedView(null)
this.list.loadFromQueryParams(queryParams)
@@ -154,16 +164,6 @@ export class DocumentListComponent implements OnInit, OnDestroy {
this.unsubscribeNotifier.complete()
}
loadViewConfig(viewId: number) {
this.savedViewService
.getCached(viewId)
.pipe(first())
.subscribe((view) => {
this.list.activateSavedView(view)
this.list.reload()
})
}
saveViewConfig() {
if (this.list.activeSavedViewId != null) {
let savedView: PaperlessSavedView = {