Merge pull request #1000 from paperless-ngx/rework-query-params-logic

Fix: Rework query params logic
This commit is contained in:
Quinn Casey
2022-05-26 08:18:43 -07:00
committed by GitHub
16 changed files with 226 additions and 278 deletions

View File

@@ -93,7 +93,7 @@
<span i18n *ngIf="list.selected.size == 0">{list.collectionSize, plural, =1 {One document} other {{{list.collectionSize || 0}} documents}}</span>&nbsp;<span i18n *ngIf="isFiltered">(filtered)</span>
</ng-container>
</p>
<ngb-pagination [pageSize]="list.currentPageSize" [collectionSize]="list.collectionSize" [(page)]="list.currentPage" [maxSize]="5"
<ngb-pagination [pageSize]="list.currentPageSize" [collectionSize]="list.collectionSize" (pageChange)="setPage($event)" [page]="list.currentPage" [maxSize]="5"
[rotate]="true" aria-label="Default pagination"></ngb-pagination>
</div>
</ng-template>

View File

@@ -1,5 +1,4 @@
import {
AfterViewInit,
Component,
OnDestroy,
OnInit,
@@ -21,7 +20,6 @@ import {
import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
import { QueryParamsService } from 'src/app/services/query-params.service'
import {
DOCUMENT_SORT_FIELDS,
DOCUMENT_SORT_FIELDS_FULLTEXT,
@@ -36,7 +34,7 @@ import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-vi
templateUrl: './document-list.component.html',
styleUrls: ['./document-list.component.scss'],
})
export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
export class DocumentListComponent implements OnInit, OnDestroy {
constructor(
public list: DocumentListViewService,
public savedViewService: SavedViewService,
@@ -45,7 +43,6 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
private toastService: ToastService,
private modalService: NgbModal,
private consumerStatusService: ConsumerStatusService,
private queryParamsService: QueryParamsService,
public openDocumentsService: OpenDocumentsService
) {}
@@ -76,8 +73,6 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
set listSort(reverse: boolean) {
this.list.sortReverse = reverse
this.queryParamsService.sortField = this.list.sortField
this.queryParamsService.sortReverse = reverse
}
get listSort(): boolean {
@@ -86,14 +81,14 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
setSortField(field: string) {
this.list.sortField = field
this.queryParamsService.sortField = field
this.queryParamsService.sortReverse = this.listSort
}
onSort(event: SortEvent) {
this.list.setSort(event.column, event.reverse)
this.queryParamsService.sortField = event.column
this.queryParamsService.sortReverse = event.reverse
}
setPage(page: number) {
this.list.currentPage = page
}
get isBulkEditing(): boolean {
@@ -133,7 +128,6 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
}
this.list.activateSavedView(view)
this.list.reload()
this.queryParamsService.updateFromView(view)
this.unmodifiedFilterRules = view.filter_rules
})
@@ -148,22 +142,12 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
this.loadViewConfig(parseInt(queryParams.get('view')))
} else {
this.list.activateSavedView(null)
this.queryParamsService.parseQueryParams(queryParams)
this.list.loadFromQueryParams(queryParams)
this.unmodifiedFilterRules = []
}
})
}
ngAfterViewInit(): void {
this.filterEditor.filterRulesChange
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe({
next: (filterRules) => {
this.queryParamsService.updateFilterRules(filterRules)
},
})
}
ngOnDestroy() {
// unsubscribes all
this.unsubscribeNotifier.next(this)
@@ -175,9 +159,8 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
.getCached(viewId)
.pipe(first())
.subscribe((view) => {
this.list.loadSavedView(view)
this.list.activateSavedView(view)
this.list.reload()
this.queryParamsService.updateFromView(view)
})
}
@@ -246,34 +229,26 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
clickTag(tagID: number) {
this.list.selectNone()
setTimeout(() => {
this.filterEditor.addTag(tagID)
})
this.filterEditor.addTag(tagID)
}
clickCorrespondent(correspondentID: number) {
this.list.selectNone()
setTimeout(() => {
this.filterEditor.addCorrespondent(correspondentID)
})
this.filterEditor.addCorrespondent(correspondentID)
}
clickDocumentType(documentTypeID: number) {
this.list.selectNone()
setTimeout(() => {
this.filterEditor.addDocumentType(documentTypeID)
})
this.filterEditor.addDocumentType(documentTypeID)
}
clickStoragePath(storagePathID: number) {
this.list.selectNone()
setTimeout(() => {
this.filterEditor.addStoragePath(storagePathID)
})
this.filterEditor.addStoragePath(storagePathID)
}
clickMoreLike(documentID: number) {
this.queryParamsService.navigateWithFilterRules([
this.list.quickFilter([
{ rule_type: FILTER_FULLTEXT_MORELIKE, value: documentID.toString() },
])
}

View File

@@ -313,7 +313,10 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
break
case FILTER_ASN_ISNULL:
this.textFilterTarget = TEXT_FILTER_TARGET_ASN
this.textFilterModifier = TEXT_FILTER_MODIFIER_NULL
this.textFilterModifier =
rule.value == 'true' || rule.value == '1'
? TEXT_FILTER_MODIFIER_NULL
: TEXT_FILTER_MODIFIER_NOTNULL
break
case FILTER_ASN_GT:
this.textFilterTarget = TEXT_FILTER_TARGET_ASN