Live document counts for document filtering

This commit is contained in:
shamoon
2023-02-18 15:44:54 -08:00
parent 05cd9d36e9
commit 4e2b2f1e8a
4 changed files with 51 additions and 6 deletions

View File

@@ -12,7 +12,11 @@ import { PaperlessSavedView } from '../data/paperless-saved-view'
import { SETTINGS_KEYS } from '../data/paperless-uisettings'
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'
import { paramsFromViewState, paramsToViewState } from '../utils/query-params'
import { DocumentService, DOCUMENT_SORT_FIELDS } from './rest/document.service'
import {
DocumentService,
DOCUMENT_SORT_FIELDS,
SelectionData,
} from './rest/document.service'
import { SettingsService } from './settings.service'
/**
@@ -74,6 +78,8 @@ export class DocumentListViewService {
rangeSelectionAnchorIndex: number
lastRangeSelectionToIndex: number
selectionData?: SelectionData
currentPageSize: number = this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE)
private listViewStates: Map<number, ListViewState> = new Map()
@@ -222,6 +228,18 @@ export class DocumentListViewService {
this.isReloading = false
activeListViewState.collectionSize = result.count
activeListViewState.documents = result.results
this.documentService
.getSelectionData(result.results.map((d) => d.id))
.subscribe({
next: (selectionData) => {
this.selectionData = selectionData
},
error: () => {
this.selectionData = null
},
})
if (updateQueryParams && !this._activeSavedViewId) {
let base = ['/documents']
this.router.navigate(base, {
@@ -247,6 +265,7 @@ export class DocumentListViewService {
activeListViewState.currentPage = 1
this.reload()
} else {
this.selectionData = null
let errorMessage
if (
typeof error.error !== 'string' &&