Handle page parameter on saved views

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

View File

@@ -147,6 +147,15 @@ export class DocumentListViewService {
}
}
activateSavedViewWithQueryParams(
view: PaperlessSavedView,
queryParams: ParamMap
) {
let params = parseParams(queryParams)
this.activateSavedView(view)
this.activeListViewState.currentPage = params.currentPage
}
loadSavedView(view: PaperlessSavedView, closeCurrentView: boolean = false) {
if (closeCurrentView) {
this._activeSavedViewId = null
@@ -212,12 +221,16 @@ export class DocumentListViewService {
this.isReloading = false
activeListViewState.collectionSize = result.count
activeListViewState.documents = result.results
if (updateQueryParams && !this._activeSavedViewId) {
let base = ['/documents']
this.router.navigate(base, {
queryParams: generateParams(activeListViewState),
})
} else if (this._activeSavedViewId) {
this.router.navigate([], {
queryParams: generateParams(activeListViewState, true),
queryParamsHandling: 'merge',
})
}
if (onFinish) {
@@ -305,7 +318,6 @@ export class DocumentListViewService {
set currentPage(page: number) {
if (this.activeListViewState.currentPage == page) return
this._activeSavedViewId = null
this.activeListViewState.currentPage = page
this.reload()
this.saveDocumentListView()