Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Add query params for saved views

Michael Shamoon584082a1dfd7
diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts
index e677a6e2f..b8bf389dd 100644
--- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts
+++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts
@@ -60,8 +60,9 @@ export class SavedViewWidgetComponent implements OnInit, OnDestroy {
if (this.savedView.show_in_sidebar) {
this.router.navigate(['view', this.savedView.id])
} else {
- this.list.loadSavedView(this.savedView, true)
- this.router.navigate(['documents'])
+ this.router.navigate(['documents'], {
+ queryParams: { view: this.savedView.id },
+ })
}
}
diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html
index 1ce61f931..f3e5605eb 100644
--- a/src-ui/src/app/components/document-list/document-list.component.html
+++ b/src-ui/src/app/components/document-list/document-list.component.html
@@ -64,7 +64,7 @@
<button class="btn btn-sm btn-outline-primary dropdown-toggle flex-fill" ngbDropdownToggle i18n>Views</button>
<div class="dropdown-menu shadow dropdown-menu-right" ngbDropdownMenu>
<ng-container *ngIf="!list.activeSavedViewId">
- <button ngbDropdownItem *ngFor="let view of savedViewService.allViews" (click)="loadViewConfig(view)">{{view.name}}</button>
+ <button ngbDropdownItem *ngFor="let view of savedViewService.allViews" (click)="loadViewConfig(view.id)">{{view.name}}</button>
<div class="dropdown-divider" *ngIf="savedViewService.allViews.length > 0"></div>
</ng-container>
diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts
index 9e058fb64..bfbf0fc47 100644
--- a/src-ui/src/app/components/document-list/document-list.component.ts
+++ b/src-ui/src/app/components/document-list/document-list.component.ts
@@ -137,32 +137,36 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
takeUntil(this.unsubscribeNotifier)
)
.subscribe((queryParams) => {
- // transform query params to filter rules
- let filterRulesFromQueryParams: FilterRule[] = []
- allFilterRuleQueryParams
- .filter((frqp) => queryParams.has(frqp))
- .forEach((filterQueryParamName) => {
- const filterQueryParamValues: string[] = queryParams
- .get(filterQueryParamName)
- .split(',')
-
- filterRulesFromQueryParams = filterRulesFromQueryParams.concat(
- // map all values to filter rules
- filterQueryParamValues.map((val) => {
- return {
- rule_type: FILTER_RULE_TYPES.find(
- (rt) => rt.filtervar == filterQueryParamName
- ).id,
- value: val,
- }
- })
- )
- })
-
- this.list.activateSavedView(null)
- this.list.filterRules = filterRulesFromQueryParams
- this.list.reload()
- this.unmodifiedFilterRules = []
+ if (queryParams.has('view')) {
+ this.loadViewConfig(parseInt(queryParams.get('view')))
+ } else {
+ // transform query params to filter rules
+ let filterRulesFromQueryParams: FilterRule[] = []
+ allFilterRuleQueryParams
+ .filter((frqp) => queryParams.has(frqp))
+ .forEach((filterQueryParamName) => {
+ const filterQueryParamValues: string[] = queryParams
+ .get(filterQueryParamName)
+ .split(',')
+
+ filterRulesFromQueryParams = filterRulesFromQueryParams.concat(
+ // map all values to filter rules
+ filterQueryParamValues.map((val) => {
+ return {
+ rule_type: FILTER_RULE_TYPES.find(
+ (rt) => rt.filtervar == filterQueryParamName
+ ).id,
+ value: val,
+ }
+ })
+ )
+ })
+
+ this.list.activateSavedView(null)
+ this.list.filterRules = filterRulesFromQueryParams
+ this.list.reload()
+ this.unmodifiedFilterRules = []
+ }
})
}
@@ -192,9 +196,19 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
this.unsubscribeNotifier.complete()
}
- loadViewConfig(view: PaperlessSavedView) {
- this.list.loadSavedView(view)
- this.list.reload()
+ loadViewConfig(viewId: number) {
+ this.savedViewService
+ .getCached(viewId)
+ .pipe(first())
+ .subscribe((view) => {
+ this.list.loadSavedView(view)
+ this.list.reload()
+ // update query params if needed
+ this.router.navigate([], {
+ relativeTo: this.route,
+ queryParams: { view: viewId },
+ })
+ })
}
saveViewConfig() {