mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Live document counts for bulk edit
This commit is contained in:
parent
abc58000b4
commit
2635c3a1a0
@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div *ngIf="selectionModel.items" class="items">
|
<div *ngIf="selectionModel.items" class="items">
|
||||||
<ng-container *ngFor="let item of selectionModel.itemsSorted | filter: filterText">
|
<ng-container *ngFor="let item of selectionModel.itemsSorted | filter: filterText">
|
||||||
<app-toggleable-dropdown-button *ngIf="allowSelectNone || item.id" [item]="item" [state]="selectionModel.get(item.id)" (toggle)="selectionModel.toggle(item.id)" (exclude)="excludeClicked(item.id)" [disabled]="disabled"></app-toggleable-dropdown-button>
|
<app-toggleable-dropdown-button *ngIf="allowSelectNone || item.id" [item]="item" [state]="selectionModel.get(item.id)" [count]="getUpdatedDocumentCount(item.id)" (toggle)="selectionModel.toggle(item.id)" (exclude)="excludeClicked(item.id)" [disabled]="disabled"></app-toggleable-dropdown-button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<button *ngIf="editing" class="list-group-item list-group-item-action bg-light" (click)="applyClicked()" [disabled]="!modelIsDirty || disabled">
|
<button *ngIf="editing" class="list-group-item list-group-item-action bg-light" (click)="applyClicked()" [disabled]="!modelIsDirty || disabled">
|
||||||
|
@ -11,6 +11,7 @@ import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
|
|||||||
import { ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component'
|
import { ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component'
|
||||||
import { MatchingModel } from 'src/app/data/matching-model'
|
import { MatchingModel } from 'src/app/data/matching-model'
|
||||||
import { Subject } from 'rxjs'
|
import { Subject } from 'rxjs'
|
||||||
|
import { SelectionDataItem } from 'src/app/services/rest/document.service'
|
||||||
|
|
||||||
export interface ChangedItems {
|
export interface ChangedItems {
|
||||||
itemsToAdd: MatchingModel[]
|
itemsToAdd: MatchingModel[]
|
||||||
@ -333,6 +334,15 @@ export class FilterableDropdownComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
documentCounts: SelectionDataItem[]
|
||||||
|
|
||||||
|
getUpdatedDocumentCount(id: number) {
|
||||||
|
if (this.documentCounts) {
|
||||||
|
return this.documentCounts.find((c) => c.id === id)?.document_count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modelIsDirty: boolean = false
|
modelIsDirty: boolean = false
|
||||||
|
|
||||||
constructor(private filterPipe: FilterPipe) {
|
constructor(private filterPipe: FilterPipe) {
|
||||||
|
@ -20,5 +20,5 @@
|
|||||||
<app-tag *ngIf="isTag; else displayName" [tag]="item" [clickable]="false"></app-tag>
|
<app-tag *ngIf="isTag; else displayName" [tag]="item" [clickable]="false"></app-tag>
|
||||||
<ng-template #displayName><small>{{item.name}}</small></ng-template>
|
<ng-template #displayName><small>{{item.name}}</small></ng-template>
|
||||||
</div>
|
</div>
|
||||||
<div class="badge badge-light rounded-pill ms-auto me-1">{{item.document_count}}</div>
|
<div class="badge badge-light rounded-pill ms-auto me-1">{{count ?? item.document_count}}</div>
|
||||||
</button>
|
</button>
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
[applyOnClose]="applyOnClose"
|
[applyOnClose]="applyOnClose"
|
||||||
(opened)="openTagsDropdown()"
|
(opened)="openTagsDropdown()"
|
||||||
[(selectionModel)]="tagSelectionModel"
|
[(selectionModel)]="tagSelectionModel"
|
||||||
|
[documentCounts]="tagDocumentCounts"
|
||||||
(apply)="setTags($event)">
|
(apply)="setTags($event)">
|
||||||
</app-filterable-dropdown>
|
</app-filterable-dropdown>
|
||||||
<app-filterable-dropdown class="me-2 me-md-3" title="Correspondent" icon="person-fill" i18n-title
|
<app-filterable-dropdown class="me-2 me-md-3" title="Correspondent" icon="person-fill" i18n-title
|
||||||
@ -44,6 +45,7 @@
|
|||||||
[applyOnClose]="applyOnClose"
|
[applyOnClose]="applyOnClose"
|
||||||
(opened)="openCorrespondentDropdown()"
|
(opened)="openCorrespondentDropdown()"
|
||||||
[(selectionModel)]="correspondentSelectionModel"
|
[(selectionModel)]="correspondentSelectionModel"
|
||||||
|
[documentCounts]="correspondentDocumentCounts"
|
||||||
(apply)="setCorrespondents($event)">
|
(apply)="setCorrespondents($event)">
|
||||||
</app-filterable-dropdown>
|
</app-filterable-dropdown>
|
||||||
<app-filterable-dropdown class="me-2 me-md-3" title="Document type" icon="file-earmark-fill" i18n-title
|
<app-filterable-dropdown class="me-2 me-md-3" title="Document type" icon="file-earmark-fill" i18n-title
|
||||||
@ -54,6 +56,7 @@
|
|||||||
[applyOnClose]="applyOnClose"
|
[applyOnClose]="applyOnClose"
|
||||||
(opened)="openDocumentTypeDropdown()"
|
(opened)="openDocumentTypeDropdown()"
|
||||||
[(selectionModel)]="documentTypeSelectionModel"
|
[(selectionModel)]="documentTypeSelectionModel"
|
||||||
|
[documentCounts]="documentTypeDocumentCounts"
|
||||||
(apply)="setDocumentTypes($event)">
|
(apply)="setDocumentTypes($event)">
|
||||||
</app-filterable-dropdown>
|
</app-filterable-dropdown>
|
||||||
<app-filterable-dropdown class="me-2 me-md-3" title="Storage path" icon="folder-fill" i18n-title
|
<app-filterable-dropdown class="me-2 me-md-3" title="Storage path" icon="folder-fill" i18n-title
|
||||||
@ -64,6 +67,7 @@
|
|||||||
[applyOnClose]="applyOnClose"
|
[applyOnClose]="applyOnClose"
|
||||||
(opened)="openStoragePathDropdown()"
|
(opened)="openStoragePathDropdown()"
|
||||||
[(selectionModel)]="storagePathsSelectionModel"
|
[(selectionModel)]="storagePathsSelectionModel"
|
||||||
|
[documentCounts]="storagePathDocumentCounts"
|
||||||
(apply)="setStoragePaths($event)">
|
(apply)="setStoragePaths($event)">
|
||||||
</app-filterable-dropdown>
|
</app-filterable-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,6 +49,10 @@ export class BulkEditorComponent
|
|||||||
correspondentSelectionModel = new FilterableDropdownSelectionModel()
|
correspondentSelectionModel = new FilterableDropdownSelectionModel()
|
||||||
documentTypeSelectionModel = new FilterableDropdownSelectionModel()
|
documentTypeSelectionModel = new FilterableDropdownSelectionModel()
|
||||||
storagePathsSelectionModel = new FilterableDropdownSelectionModel()
|
storagePathsSelectionModel = new FilterableDropdownSelectionModel()
|
||||||
|
tagDocumentCounts: SelectionDataItem[]
|
||||||
|
correspondentDocumentCounts: SelectionDataItem[]
|
||||||
|
documentTypeDocumentCounts: SelectionDataItem[]
|
||||||
|
storagePathDocumentCounts: SelectionDataItem[]
|
||||||
awaitingDownload: boolean
|
awaitingDownload: boolean
|
||||||
|
|
||||||
unsubscribeNotifier: Subject<any> = new Subject()
|
unsubscribeNotifier: Subject<any> = new Subject()
|
||||||
@ -197,6 +201,7 @@ export class BulkEditorComponent
|
|||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData(Array.from(this.list.selected))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
|
this.tagDocumentCounts = s.selected_tags
|
||||||
this.applySelectionData(s.selected_tags, this.tagSelectionModel)
|
this.applySelectionData(s.selected_tags, this.tagSelectionModel)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -206,6 +211,7 @@ export class BulkEditorComponent
|
|||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData(Array.from(this.list.selected))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
|
this.documentTypeDocumentCounts = s.selected_document_types
|
||||||
this.applySelectionData(
|
this.applySelectionData(
|
||||||
s.selected_document_types,
|
s.selected_document_types,
|
||||||
this.documentTypeSelectionModel
|
this.documentTypeSelectionModel
|
||||||
@ -218,6 +224,7 @@ export class BulkEditorComponent
|
|||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData(Array.from(this.list.selected))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
|
this.correspondentDocumentCounts = s.selected_correspondents
|
||||||
this.applySelectionData(
|
this.applySelectionData(
|
||||||
s.selected_correspondents,
|
s.selected_correspondents,
|
||||||
this.correspondentSelectionModel
|
this.correspondentSelectionModel
|
||||||
@ -230,6 +237,7 @@ export class BulkEditorComponent
|
|||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData(Array.from(this.list.selected))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
|
this.storagePathDocumentCounts = s.selected_storage_paths
|
||||||
this.applySelectionData(
|
this.applySelectionData(
|
||||||
s.selected_storage_paths,
|
s.selected_storage_paths,
|
||||||
this.storagePathsSelectionModel
|
this.storagePathsSelectionModel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user