From ef1ee8e0c0acadaaa9d4778dee69f60d1beab5a6 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Wed, 30 Dec 2020 23:34:50 +0100 Subject: [PATCH] fixes a bug with invisible selection --- .../correspondent-list.component.ts | 9 ++------- .../document-type-list.component.ts | 7 +------ .../components/manage/tag-list/tag-list.component.ts | 9 ++------- src-ui/src/app/services/document-list-view.service.ts | 11 ++++++++++- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts b/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts index d3b71b4ab..37b6fa66e 100644 --- a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts +++ b/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts @@ -1,5 +1,4 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; +import { Component } from '@angular/core'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { FILTER_CORRESPONDENT } from 'src/app/data/filter-rule-type'; import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'; @@ -16,7 +15,6 @@ import { CorrespondentEditDialogComponent } from './correspondent-edit-dialog/co export class CorrespondentListComponent extends GenericListComponent { constructor(correspondentsService: CorrespondentService, modalService: NgbModal, - private router: Router, private list: DocumentListViewService ) { super(correspondentsService,modalService,CorrespondentEditDialogComponent) @@ -27,9 +25,6 @@ export class CorrespondentListComponent extends GenericListComponent { constructor(service: DocumentTypeService, modalService: NgbModal, - private router: Router, private list: DocumentListViewService ) { super(service, modalService, DocumentTypeEditDialogComponent) @@ -28,9 +26,6 @@ export class DocumentTypeListComponent extends GenericListComponent { constructor(tagService: TagService, modalService: NgbModal, - private router: Router, private list: DocumentListViewService ) { super(tagService, modalService, TagEditDialogComponent) @@ -27,14 +25,11 @@ export class TagListComponent extends GenericListComponent { } getDeleteMessage(object: PaperlessTag) { - return $localize`Do you really want to delete the tag "${object.name}"?` } filterDocuments(object: PaperlessTag) { - this.list.documentListView.filter_rules = [ - {rule_type: FILTER_HAS_TAG, value: object.id.toString()} - ] - this.router.navigate(["documents"]) + this.list.quickFilter([{rule_type: FILTER_HAS_TAG, value: object.id.toString()}]) + } } diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts index dfcf9c0c5..eb69439ec 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; import { Observable } from 'rxjs'; import { cloneFilterRules, FilterRule } from '../data/filter-rule'; import { PaperlessDocument } from '../data/paperless-document'; @@ -155,6 +156,14 @@ export class DocumentListViewService { sessionStorage.setItem(DOCUMENT_LIST_SERVICE.CURRENT_VIEW_CONFIG, JSON.stringify(this.documentListView)) } + quickFilter(filterRules: FilterRule[]) { + this.savedView = null + this.view.filter_rules = filterRules + this.reduceSelectionToFilter() + this.saveDocumentListView() + this.router.navigate(["documents"]) + } + getLastPage(): number { return Math.ceil(this.collectionSize / this.currentPageSize) } @@ -240,7 +249,7 @@ export class DocumentListViewService { } } - constructor(private documentService: DocumentService, private settings: SettingsService) { + constructor(private documentService: DocumentService, private settings: SettingsService, private router: Router) { let documentListViewConfigJson = sessionStorage.getItem(DOCUMENT_LIST_SERVICE.CURRENT_VIEW_CONFIG) if (documentListViewConfigJson) { try {