mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Add query params for saved views
This commit is contained in:
		| @@ -60,8 +60,9 @@ export class SavedViewWidgetComponent implements OnInit, OnDestroy { | |||||||
|     if (this.savedView.show_in_sidebar) { |     if (this.savedView.show_in_sidebar) { | ||||||
|       this.router.navigate(['view', this.savedView.id]) |       this.router.navigate(['view', this.savedView.id]) | ||||||
|     } else { |     } else { | ||||||
|       this.list.loadSavedView(this.savedView, true) |       this.router.navigate(['documents'], { | ||||||
|       this.router.navigate(['documents']) |         queryParams: { view: this.savedView.id }, | ||||||
|  |       }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -64,7 +64,7 @@ | |||||||
|     <button class="btn btn-sm btn-outline-primary dropdown-toggle flex-fill" ngbDropdownToggle i18n>Views</button> |     <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> |     <div class="dropdown-menu shadow dropdown-menu-right" ngbDropdownMenu> | ||||||
|       <ng-container *ngIf="!list.activeSavedViewId"> |       <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> |         <div class="dropdown-divider" *ngIf="savedViewService.allViews.length > 0"></div> | ||||||
|       </ng-container> |       </ng-container> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -137,6 +137,9 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit { | |||||||
|         takeUntil(this.unsubscribeNotifier) |         takeUntil(this.unsubscribeNotifier) | ||||||
|       ) |       ) | ||||||
|       .subscribe((queryParams) => { |       .subscribe((queryParams) => { | ||||||
|  |         if (queryParams.has('view')) { | ||||||
|  |           this.loadViewConfig(parseInt(queryParams.get('view'))) | ||||||
|  |         } else { | ||||||
|           // transform query params to filter rules |           // transform query params to filter rules | ||||||
|           let filterRulesFromQueryParams: FilterRule[] = [] |           let filterRulesFromQueryParams: FilterRule[] = [] | ||||||
|           allFilterRuleQueryParams |           allFilterRuleQueryParams | ||||||
| @@ -163,6 +166,7 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit { | |||||||
|           this.list.filterRules = filterRulesFromQueryParams |           this.list.filterRules = filterRulesFromQueryParams | ||||||
|           this.list.reload() |           this.list.reload() | ||||||
|           this.unmodifiedFilterRules = [] |           this.unmodifiedFilterRules = [] | ||||||
|  |         } | ||||||
|       }) |       }) | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -192,9 +196,19 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit { | |||||||
|     this.unsubscribeNotifier.complete() |     this.unsubscribeNotifier.complete() | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   loadViewConfig(view: PaperlessSavedView) { |   loadViewConfig(viewId: number) { | ||||||
|  |     this.savedViewService | ||||||
|  |       .getCached(viewId) | ||||||
|  |       .pipe(first()) | ||||||
|  |       .subscribe((view) => { | ||||||
|         this.list.loadSavedView(view) |         this.list.loadSavedView(view) | ||||||
|         this.list.reload() |         this.list.reload() | ||||||
|  |         // update query params if needed | ||||||
|  |         this.router.navigate([], { | ||||||
|  |           relativeTo: this.route, | ||||||
|  |           queryParams: { view: viewId }, | ||||||
|  |         }) | ||||||
|  |       }) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   saveViewConfig() { |   saveViewConfig() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon