mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Dynamic counts include all pages, hide for "Any"
This commit is contained in:
		| @@ -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,13 +230,21 @@ 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({ |             .subscribe({ | ||||||
|               next: (selectionData) => { |               next: (ids: number[]) => { | ||||||
|                 this.selectionData = selectionData |                 this.documentService | ||||||
|               }, |                   .getSelectionData(ids) | ||||||
|               error: () => { |                   .pipe(first()) | ||||||
|                 this.selectionData = null |                   .subscribe({ | ||||||
|  |                     next: (selectionData) => { | ||||||
|  |                       this.selectionData = selectionData | ||||||
|  |                     }, | ||||||
|  |                     error: () => { | ||||||
|  |                       this.selectionData = null | ||||||
|  |                     }, | ||||||
|  |                   }) | ||||||
|               }, |               }, | ||||||
|             }) |             }) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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 | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon