mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-19 10:19:27 -05:00
Dynamic counts include all pages, hide for "Any"
This commit is contained in:
parent
02875f5a34
commit
c59420581c
@ -34,7 +34,7 @@
|
|||||||
<div *ngIf="selectionModel.items" class="items" #buttonItems>
|
<div *ngIf="selectionModel.items" class="items" #buttonItems>
|
||||||
<ng-container *ngFor="let item of selectionModel.itemsSorted | filter: filterText; let i = index">
|
<ng-container *ngFor="let item of selectionModel.itemsSorted | filter: filterText; let i = index">
|
||||||
<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)" (click)="setButtonItemIndex(i)" [disabled]="disabled">
|
*ngIf="allowSelectNone || item.id" [item]="item" [hideCount]="hideCount(item)" [state]="selectionModel.get(item.id)" [count]="getUpdatedDocumentCount(item.id)" (toggle)="selectionModel.toggle(item.id)" (exclude)="excludeClicked(item.id)" (click)="setButtonItemIndex(i)" [disabled]="disabled">
|
||||||
</app-toggleable-dropdown-button>
|
</app-toggleable-dropdown-button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,6 +12,7 @@ import { ToggleableItemState } from './toggleable-dropdown-button/toggleable-dro
|
|||||||
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'
|
import { SelectionDataItem } from 'src/app/services/rest/document.service'
|
||||||
|
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
|
||||||
|
|
||||||
export interface ChangedItems {
|
export interface ChangedItems {
|
||||||
itemsToAdd: MatchingModel[]
|
itemsToAdd: MatchingModel[]
|
||||||
@ -552,4 +553,13 @@ export class FilterableDropdownComponent {
|
|||||||
// just track the index in case user uses arrows
|
// just track the index in case user uses arrows
|
||||||
this.keyboardIndex = index
|
this.keyboardIndex = index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideCount(item: ObjectWithPermissions) {
|
||||||
|
// counts are pointless when clicking item would add to the set of docs
|
||||||
|
return (
|
||||||
|
this.selectionModel.logicalOperator === LogicalOperator.Or &&
|
||||||
|
this.manyToOne &&
|
||||||
|
this.selectionModel.get(item.id) !== ToggleableItemState.Selected
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 bg-light text-dark rounded-pill ms-auto me-1">{{count ?? item.document_count}}</div>
|
<div *ngIf="!hideCount" class="badge bg-light text-dark rounded-pill ms-auto me-1">{{count ?? item.document_count}}</div>
|
||||||
</button>
|
</button>
|
||||||
|
@ -26,6 +26,9 @@ export class ToggleableDropdownButtonComponent {
|
|||||||
@Input()
|
@Input()
|
||||||
disabled: boolean = false
|
disabled: boolean = false
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
hideCount: boolean = false
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
toggle = new EventEmitter()
|
toggle = new EventEmitter()
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { ParamMap, Router } from '@angular/router'
|
import { ParamMap, Router } from '@angular/router'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable, first } from 'rxjs'
|
||||||
import {
|
import {
|
||||||
filterRulesDiffer,
|
filterRulesDiffer,
|
||||||
cloneFilterRules,
|
cloneFilterRules,
|
||||||
@ -230,7 +230,13 @@ export class DocumentListViewService {
|
|||||||
activeListViewState.documents = result.results
|
activeListViewState.documents = result.results
|
||||||
|
|
||||||
this.documentService
|
this.documentService
|
||||||
.getSelectionData(result.results.map((d) => d.id))
|
.listAllFilteredIds(activeListViewState.filterRules)
|
||||||
|
.pipe(first())
|
||||||
|
.subscribe({
|
||||||
|
next: (ids: number[]) => {
|
||||||
|
this.documentService
|
||||||
|
.getSelectionData(ids)
|
||||||
|
.pipe(first())
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (selectionData) => {
|
next: (selectionData) => {
|
||||||
this.selectionData = selectionData
|
this.selectionData = selectionData
|
||||||
@ -239,6 +245,8 @@ export class DocumentListViewService {
|
|||||||
this.selectionData = null
|
this.selectionData = null
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
if (updateQueryParams && !this._activeSavedViewId) {
|
if (updateQueryParams && !this._activeSavedViewId) {
|
||||||
let base = ['/documents']
|
let base = ['/documents']
|
||||||
|
@ -422,7 +422,7 @@ class DocumentSerializer(OwnedObjectSerializer, DynamicFieldsModelSerializer):
|
|||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
doc = super().to_representation(instance)
|
doc = super().to_representation(instance)
|
||||||
if self.truncate_content:
|
if self.truncate_content and "content" in self.fields:
|
||||||
doc["content"] = doc.get("content")[0:550]
|
doc["content"] = doc.get("content")[0:550]
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user